UNPKG

one

Version:

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

99 lines (97 loc) 3.07 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 getReactNavigationConfig_exports = {}; __export(getReactNavigationConfig_exports, { getReactNavigationConfig: () => getReactNavigationConfig }); module.exports = __toCommonJS(getReactNavigationConfig_exports); var import_matchers = require("./router/matchers.native.js"); function convertDynamicRouteToReactNavigation(segment) { if (segment === "index") { return ""; } if (segment === "+not-found") { return "*not-found"; } var dynamicMatch = (0, import_matchers.matchDynamicName)(segment); if (dynamicMatch) { if (dynamicMatch.deep) { return "*" + dynamicMatch.name; } return `:${dynamicMatch.name}`; } return segment; } function parseRouteSegments(segments) { return ( // NOTE: When there are nested routes without layouts // the node.route will be something like `app/home/index` // this needs to be split to ensure each segment is parsed correctly. segments.split("/").map(convertDynamicRouteToReactNavigation).filter(Boolean).join("/") ); } function convertRouteNodeToScreen(node, metaOnly) { var path = parseRouteSegments(node.route); if (!node.children.length) { if (!metaOnly) { return { path, screens: {}, _route: node }; } return path; } var screens = getReactNavigationScreensConfig(node.children, metaOnly); var screen = { path, screens, // NOTE: This is bad because it forces all Layout Routes // to be loaded into memory. We should move towards a system where // the initial route name is either loaded asynchronously in the Layout Route // or defined via a file system convention. initialRouteName: node.initialRouteName }; if (!metaOnly) { screen._route = node; } return screen; } function getReactNavigationScreensConfig(nodes, metaOnly) { return Object.fromEntries(nodes.map(function (node) { return [node.route, convertRouteNodeToScreen(node, metaOnly)]; })); } function getReactNavigationConfig(routes, metaOnly) { if (!routes) { return { screens: {} }; } return { initialRouteName: routes.initialRouteName, screens: getReactNavigationScreensConfig(routes.children, metaOnly) }; } //# sourceMappingURL=getReactNavigationConfig.native.js.map