UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

58 lines (57 loc) 2.58 kB
import { getActionFromState } from "@react-navigation/native"; import { getReactNavigationConfig } from "../getReactNavigationConfig.native.js"; import { addEventListener, getDefaultLinkingPrefixes, getInitialURL, getPathFromState, getStateFromPath } from "../link/linking.native.js"; import { normalizeLinkingConfig } from "../link/getLinking.native.js"; import { evictOldest } from "../utils/evictOldest.native.js"; function getNavigationConfig(routes) { var metaOnly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; return getReactNavigationConfig(routes, metaOnly); } function getLinkingConfig(routes) { var metaOnly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true, linking = arguments.length > 2 ? arguments[2] : void 0; var config = getNavigationConfig(routes, metaOnly); var resolvedLinking = normalizeLinkingConfig(linking, getDefaultLinkingPrefixes()); return { prefixes: resolvedLinking.prefixes, filter: resolvedLinking.filter, // @ts-expect-error config, // A custom getInitialURL is used on native to ensure the app always starts at // the root path if it's launched from something other than a deep link. // This helps keep the native functionality working like the web functionality. // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index` // then `/index` would be used on web and `/settings` would be used on native. getInitialURL, subscribe: addEventListener, getStateFromPath: getStateFromPathMemoized, getPathFromState(state, options) { var _getPathFromState; return (_getPathFromState = getPathFromState(state, { ...config, ...options })) !== null && _getPathFromState !== void 0 ? _getPathFromState : "/"; }, // Add all functions to ensure the types never need to fallback. // This is a convenience for usage in the package. getActionFromState }; } var stateCache = /* @__PURE__ */new Map(); var STATE_CACHE_THRESHOLD = 5e3; var STATE_CACHE_EVICTION = 1e3; function clearStateCache() { stateCache.clear(); } function getStateFromPathMemoized(path, options) { var cached = stateCache.get(path); if (cached) { return cached; } var result = getStateFromPath(path, options); evictOldest(stateCache, STATE_CACHE_THRESHOLD, STATE_CACHE_EVICTION); stateCache.set(path, result); return result; } export { clearStateCache, getLinkingConfig, getNavigationConfig, stateCache }; //# sourceMappingURL=getLinkingConfig.native.js.map