UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 1.65 kB
{"version":3,"file":"getRouteArtifactPath.js","names":[],"sources":["esm/router/getRouteArtifactPath.js"],"sourcesContent":["import { getPathnameFromFilePath } from \"../utils/getPathnameFromFilePath\";\nimport { findRouteNodeFromState } from \"./findRouteNode\";\nfunction getRouteArtifactPaths(href, linking, rootNode) {\n const fallback = { loader: href, preload: href };\n if (!linking?.getStateFromPath || !rootNode) return fallback;\n const state = linking.getStateFromPath(href, linking.config);\n const route = findRouteNodeFromState(state, rootNode);\n if (!route) return fallback;\n const pattern = getPathnameFromFilePath(route.contextKey.replace(/^\\.\\//, \"/\"));\n if (route.type === \"spa\") {\n const hasExplicitSpaMode = route.contextKey.split(\"/\").some((segment) => /\\+spa(?:\\.|$)/.test(segment));\n const path = hasExplicitSpaMode ? pattern : href;\n return { loader: path, preload: path };\n }\n return {\n loader: href,\n preload: route.type === \"ssg\" ? href : pattern\n };\n}\nexport {\n getRouteArtifactPaths\n};\n//# sourceMappingURL=getRouteArtifactPath.js.map\n"],"mappings":";;;;AAEA,SAAS,sBAAsB,MAAM,SAAS,UAAU;CACtD,MAAM,WAAW;EAAE,QAAQ;EAAM,SAAS;CAAK;CAC/C,IAAI,CAAC,SAAS,oBAAoB,CAAC,UAAU,OAAO;CACpD,MAAM,QAAQ,QAAQ,iBAAiB,MAAM,QAAQ,MAAM;CAC3D,MAAM,QAAQ,uBAAuB,OAAO,QAAQ;CACpD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,UAAU,wBAAwB,MAAM,WAAW,QAAQ,SAAS,GAAG,CAAC;CAC9E,IAAI,MAAM,SAAS,OAAO;EACxB,MAAM,qBAAqB,MAAM,WAAW,MAAM,GAAG,CAAC,CAAC,MAAM,YAAY,gBAAgB,KAAK,OAAO,CAAC;EACtG,MAAM,OAAO,qBAAqB,UAAU;EAC5C,OAAO;GAAE,QAAQ;GAAM,SAAS;EAAK;CACvC;CACA,OAAO;EACL,QAAQ;EACR,SAAS,MAAM,SAAS,QAAQ,OAAO;CACzC;AACF"}