UNPKG

one

Version:

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

81 lines (75 loc) 3.34 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: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__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: !0 }), mod); var validatePathConfig_exports = {}; __export(validatePathConfig_exports, { validatePathConfig: () => validatePathConfig }); module.exports = __toCommonJS(validatePathConfig_exports); function _type_of(obj) { "@swc/helpers - typeof"; return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj; } var formatToList = function (items) { return Object.entries(items).map(function (param) { var [key, value] = param; return `- ${key} (${value})`; }).join(` `); }; function validatePathConfig(config) { var root = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, validation = { path: "string", initialRouteName: "string", screens: "object", // @modified - start preserveDynamicRoutes: "boolean", preserveGroups: "boolean", // @modified - end ...(root ? null : { exact: "boolean", stringify: "object", parse: "object" }) }; if ((typeof config > "u" ? "undefined" : _type_of(config)) !== "object" || config === null) throw new Error(`Expected the configuration to be an object, but got ${JSON.stringify(config)}.`); var validationErrors = Object.fromEntries(Object.keys(config).map(function (key) { if (key in validation) { var type = validation[key], value = config[key]; if (value !== void 0 && (typeof value > "u" ? "undefined" : _type_of(value)) !== type) return [key, `expected '${type}', got '${typeof value > "u" ? "undefined" : _type_of(value)}'`]; } else return [key, "extraneous"]; return null; }).filter(Boolean)); if (Object.keys(validationErrors).length) throw new Error(`Found invalid properties in the configuration: ${formatToList(validationErrors)} You can only specify the following properties: ${formatToList(validation)} If you want to specify configuration for screens, you need to specify them under a 'screens' property. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`); if (root && "path" in config && typeof config.path == "string" && config.path.includes(":")) throw new Error(`Found invalid path '${config.path}'. The 'path' in the top-level configuration cannot contain patterns for params.`); "screens" in config && config.screens && Object.entries(config.screens).forEach(function (param) { var [_, value] = param; typeof value != "string" && validatePathConfig(value, !1); }); } //# sourceMappingURL=validatePathConfig.native.js.map