UNPKG

one

Version:

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

89 lines (87 loc) 3.75 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var getLinkingConfig_exports = {}; __export(getLinkingConfig_exports, { clearStateCache: () => clearStateCache, getLinkingConfig: () => getLinkingConfig, getNavigationConfig: () => getNavigationConfig, stateCache: () => stateCache }); module.exports = __toCommonJS(getLinkingConfig_exports); var import_native = require("@react-navigation/native"); var import_getReactNavigationConfig = require("../getReactNavigationConfig.native.js"); var import_linking = require("../link/linking.native.js"); var import_getLinking = require("../link/getLinking.native.js"); var import_evictOldest = require("../utils/evictOldest.native.js"); function getNavigationConfig(routes) { var metaOnly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; return (0, import_getReactNavigationConfig.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 = (0, import_getLinking.normalizeLinkingConfig)(linking, (0, import_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: import_linking.getInitialURL, subscribe: import_linking.addEventListener, getStateFromPath: getStateFromPathMemoized, getPathFromState(state, options) { var _getPathFromState; return (_getPathFromState = (0, import_linking.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: import_native.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 = (0, import_linking.getStateFromPath)(path, options); (0, import_evictOldest.evictOldest)(stateCache, STATE_CACHE_THRESHOLD, STATE_CACHE_EVICTION); stateCache.set(path, result); return result; } //# sourceMappingURL=getLinkingConfig.native.js.map