UNPKG

2.21 kBSource Map (JSON)View Raw
1{"version":3,"names":["formatToList","items","map","key","join","validatePathConfig","config","root","validKeys","push","invalidKeys","Object","keys","filter","includes","length","Error","screens","entries","forEach","_","value"],"sources":["validatePathConfig.tsx"],"sourcesContent":["const formatToList = (items: string[]) =>\n items.map((key) => `- ${key}`).join('\\n');\n\nexport default function validatePathConfig(config: any, root = true) {\n const validKeys = ['initialRouteName', 'screens'];\n\n if (!root) {\n validKeys.push('path', 'exact', 'stringify', 'parse');\n }\n\n const invalidKeys = Object.keys(config).filter(\n (key) => !validKeys.includes(key)\n );\n\n if (invalidKeys.length) {\n throw new Error(\n `Found invalid properties in the configuration:\\n${formatToList(\n invalidKeys\n )}\\n\\nDid you forget to specify them under a 'screens' property?\\n\\nYou can only specify the following properties:\\n${formatToList(\n validKeys\n )}\\n\\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`\n );\n }\n\n if (config.screens) {\n Object.entries(config.screens).forEach(([_, value]) => {\n if (typeof value !== 'string') {\n validatePathConfig(value, false);\n }\n });\n }\n}\n"],"mappings":"AAAA,MAAMA,YAAY,GAAIC,KAAD,IACnBA,KAAK,CAACC,GAAN,CAAWC,GAAD,IAAU,KAAIA,GAAI,EAA5B,EAA+BC,IAA/B,CAAoC,IAApC,CADF;;AAGA,eAAe,SAASC,kBAAT,CAA4BC,MAA5B,EAAsD;EAAA,IAAbC,IAAa,uEAAN,IAAM;EACnE,MAAMC,SAAS,GAAG,CAAC,kBAAD,EAAqB,SAArB,CAAlB;;EAEA,IAAI,CAACD,IAAL,EAAW;IACTC,SAAS,CAACC,IAAV,CAAe,MAAf,EAAuB,OAAvB,EAAgC,WAAhC,EAA6C,OAA7C;EACD;;EAED,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYN,MAAZ,EAAoBO,MAApB,CACjBV,GAAD,IAAS,CAACK,SAAS,CAACM,QAAV,CAAmBX,GAAnB,CADQ,CAApB;;EAIA,IAAIO,WAAW,CAACK,MAAhB,EAAwB;IACtB,MAAM,IAAIC,KAAJ,CACH,mDAAkDhB,YAAY,CAC7DU,WAD6D,CAE7D,qHAAoHV,YAAY,CAChIQ,SADgI,CAEhI,wHALE,CAAN;EAOD;;EAED,IAAIF,MAAM,CAACW,OAAX,EAAoB;IAClBN,MAAM,CAACO,OAAP,CAAeZ,MAAM,CAACW,OAAtB,EAA+BE,OAA/B,CAAuC,QAAgB;MAAA,IAAf,CAACC,CAAD,EAAIC,KAAJ,CAAe;;MACrD,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;QAC7BhB,kBAAkB,CAACgB,KAAD,EAAQ,KAAR,CAAlB;MACD;IACF,CAJD;EAKD;AACF"}
\No newline at end of file