repoweaver
Version:
A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies
1 lines • 9.02 kB
JSON
{"ast":null,"code":"\"use strict\";\n\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\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 * as React from 'react';\nimport { NavigationBuilderContext } from \"./NavigationBuilderContext.js\";\nimport { NavigationRouteContext } from \"./NavigationRouteContext.js\";\nvar VISITED_ROUTE_KEYS = Symbol('VISITED_ROUTE_KEYS');\nexport var shouldPreventRemove = function shouldPreventRemove(emitter, beforeRemoveListeners, currentRoutes, nextRoutes, action) {\n var _action$VISITED_ROUTE;\n var nextRouteKeys = nextRoutes.map(function (route) {\n return route.key;\n });\n var removedRoutes = currentRoutes.filter(function (route) {\n return !nextRouteKeys.includes(route.key);\n }).reverse();\n var visitedRouteKeys = (_action$VISITED_ROUTE = action[VISITED_ROUTE_KEYS]) != null ? _action$VISITED_ROUTE : new Set();\n var beforeRemoveAction = _objectSpread(_objectSpread({}, action), {}, _defineProperty({}, VISITED_ROUTE_KEYS, visitedRouteKeys));\n for (var route of removedRoutes) {\n var _beforeRemoveListener;\n if (visitedRouteKeys.has(route.key)) {\n continue;\n }\n var isPrevented = (_beforeRemoveListener = beforeRemoveListeners[route.key]) == null ? void 0 : _beforeRemoveListener.call(beforeRemoveListeners, beforeRemoveAction);\n if (isPrevented) {\n return true;\n }\n visitedRouteKeys.add(route.key);\n var event = emitter.emit({\n type: 'beforeRemove',\n target: route.key,\n data: {\n action: beforeRemoveAction\n },\n canPreventDefault: true\n });\n if (event.defaultPrevented) {\n return true;\n }\n }\n return false;\n};\nexport function useOnPreventRemove(_ref) {\n var getState = _ref.getState,\n emitter = _ref.emitter,\n beforeRemoveListeners = _ref.beforeRemoveListeners;\n var _React$useContext = React.useContext(NavigationBuilderContext),\n addKeyedListener = _React$useContext.addKeyedListener;\n var route = React.useContext(NavigationRouteContext);\n var routeKey = route == null ? void 0 : route.key;\n React.useEffect(function () {\n if (routeKey) {\n return addKeyedListener == null ? void 0 : addKeyedListener('beforeRemove', routeKey, function (action) {\n var state = getState();\n return shouldPreventRemove(emitter, beforeRemoveListeners, state.routes, [], action);\n });\n }\n }, [addKeyedListener, beforeRemoveListeners, emitter, getState, routeKey]);\n}","map":{"version":3,"names":["React","NavigationBuilderContext","NavigationRouteContext","VISITED_ROUTE_KEYS","Symbol","shouldPreventRemove","emitter","beforeRemoveListeners","currentRoutes","nextRoutes","action","_action$VISITED_ROUTE","nextRouteKeys","map","route","key","removedRoutes","filter","includes","reverse","visitedRouteKeys","Set","beforeRemoveAction","_objectSpread","_defineProperty","_beforeRemoveListener","has","isPrevented","call","add","event","emit","type","target","data","canPreventDefault","defaultPrevented","useOnPreventRemove","_ref","getState","_React$useContext","useContext","addKeyedListener","routeKey","useEffect","state","routes"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/core/src/useOnPreventRemove.tsx"],"sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport {\n type ChildBeforeRemoveListener,\n NavigationBuilderContext,\n} from './NavigationBuilderContext';\nimport { NavigationRouteContext } from './NavigationRouteContext';\nimport type { EventMapCore } from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\n\ntype Options = {\n getState: () => NavigationState;\n emitter: NavigationEventEmitter<EventMapCore<any>>;\n beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>;\n};\n\nconst VISITED_ROUTE_KEYS = Symbol('VISITED_ROUTE_KEYS');\n\nexport const shouldPreventRemove = (\n emitter: NavigationEventEmitter<EventMapCore<any>>,\n beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>,\n currentRoutes: { key: string }[],\n nextRoutes: { key?: string | undefined }[],\n action: NavigationAction\n) => {\n const nextRouteKeys = nextRoutes.map((route) => route.key);\n\n // Call these in reverse order so last screens handle the event first\n const removedRoutes = currentRoutes\n .filter((route) => !nextRouteKeys.includes(route.key))\n .reverse();\n\n const visitedRouteKeys: Set<string> =\n // @ts-expect-error: add this property to mark that we've already emitted this action\n action[VISITED_ROUTE_KEYS] ?? new Set<string>();\n\n const beforeRemoveAction = {\n ...action,\n [VISITED_ROUTE_KEYS]: visitedRouteKeys,\n };\n\n for (const route of removedRoutes) {\n if (visitedRouteKeys.has(route.key)) {\n // Skip if we've already emitted this action for this screen\n continue;\n }\n\n // First, we need to check if any child screens want to prevent it\n const isPrevented = beforeRemoveListeners[route.key]?.(beforeRemoveAction);\n\n if (isPrevented) {\n return true;\n }\n\n visitedRouteKeys.add(route.key);\n\n const event = emitter.emit({\n type: 'beforeRemove',\n target: route.key,\n data: { action: beforeRemoveAction },\n canPreventDefault: true,\n });\n\n if (event.defaultPrevented) {\n return true;\n }\n }\n\n return false;\n};\n\nexport function useOnPreventRemove({\n getState,\n emitter,\n beforeRemoveListeners,\n}: Options) {\n const { addKeyedListener } = React.useContext(NavigationBuilderContext);\n const route = React.useContext(NavigationRouteContext);\n const routeKey = route?.key;\n\n React.useEffect(() => {\n if (routeKey) {\n return addKeyedListener?.('beforeRemove', routeKey, (action) => {\n const state = getState();\n\n return shouldPreventRemove(\n emitter,\n beforeRemoveListeners,\n state.routes,\n [],\n action\n );\n });\n }\n }, [addKeyedListener, beforeRemoveListeners, emitter, getState, routeKey]);\n}\n"],"mappings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