one
Version:
One is a React framework for web, iOS, and Android apps.
1 lines • 2.61 kB
Source Map (JSON)
{"version":3,"file":"routeIndex.js","names":[],"sources":["esm/utils/routeIndex.js"],"sourcesContent":["import micromatch from \"micromatch\";\nimport path from \"node:path\";\nimport { globDir } from \"./globDir\";\nimport { isPathInsideDirectory, isRouteFilePath } from \"./routeFileWatch\";\nfunction getRoutePaths(routerRoot, ignoredRouteFiles) {\n const routePaths = globDir(routerRoot).filter(\n (routePath) => !routePath.endsWith(\".d.ts\")\n );\n if (!ignoredRouteFiles?.length) return routePaths;\n return micromatch.not(routePaths, ignoredRouteFiles, { matchBase: true });\n}\nfunction createRouteIndex({\n routerRoot,\n ignoredRouteFiles\n}) {\n const absoluteRouterRoot = path.resolve(routerRoot);\n const routePaths = new Set(getRoutePaths(absoluteRouterRoot, ignoredRouteFiles));\n return {\n getPaths() {\n return [...routePaths].sort();\n },\n update(event, filePath) {\n if (event !== \"add\" && event !== \"delete\" && event !== \"unlink\") return false;\n if (!isPathInsideDirectory(filePath, absoluteRouterRoot)) return false;\n if (!isRouteFilePath(filePath)) return false;\n const relativePath = path.relative(absoluteRouterRoot, path.resolve(filePath)).replaceAll(\"\\\\\", \"/\");\n const routePath = `./${relativePath}`;\n if (ignoredRouteFiles?.length && micromatch.isMatch(routePath, ignoredRouteFiles, { matchBase: true })) {\n return false;\n }\n if (event === \"add\") {\n const size = routePaths.size;\n routePaths.add(routePath);\n return routePaths.size !== size;\n }\n return routePaths.delete(routePath);\n }\n };\n}\nexport {\n createRouteIndex,\n getRoutePaths\n};\n//# sourceMappingURL=routeIndex.js.map\n"],"mappings":";;;;;;AAIA,SAAS,cAAc,YAAY,mBAAmB;CACpD,MAAM,aAAa,QAAQ,UAAU,CAAC,CAAC,QACpC,cAAc,CAAC,UAAU,SAAS,OAAO,CAC5C;CACA,IAAI,CAAC,mBAAmB,QAAQ,OAAO;CACvC,OAAO,WAAW,IAAI,YAAY,mBAAmB,EAAE,WAAW,KAAK,CAAC;AAC1E;AACA,SAAS,iBAAiB,EACxB,YACA,qBACC;CACD,MAAM,qBAAqB,KAAK,QAAQ,UAAU;CAClD,MAAM,aAAa,IAAI,IAAI,cAAc,oBAAoB,iBAAiB,CAAC;CAC/E,OAAO;EACL,WAAW;GACT,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,KAAK;EAC9B;EACA,OAAO,OAAO,UAAU;GACtB,IAAI,UAAU,SAAS,UAAU,YAAY,UAAU,UAAU,OAAO;GACxE,IAAI,CAAC,sBAAsB,UAAU,kBAAkB,GAAG,OAAO;GACjE,IAAI,CAAC,gBAAgB,QAAQ,GAAG,OAAO;GACvC,MAAM,eAAe,KAAK,SAAS,oBAAoB,KAAK,QAAQ,QAAQ,CAAC,CAAC,CAAC,WAAW,MAAM,GAAG;GACnG,MAAM,YAAY,KAAK;GACvB,IAAI,mBAAmB,UAAU,WAAW,QAAQ,WAAW,mBAAmB,EAAE,WAAW,KAAK,CAAC,GAAG;IACtG,OAAO;GACT;GACA,IAAI,UAAU,OAAO;IACnB,MAAM,OAAO,WAAW;IACxB,WAAW,IAAI,SAAS;IACxB,OAAO,WAAW,SAAS;GAC7B;GACA,OAAO,WAAW,OAAO,SAAS;EACpC;CACF;AACF"}