@route-intelligence/tanstack 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +100 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FrameworkPlugin } from '@route-intelligence/shared';
|
|
2
|
+
|
|
3
|
+
interface TanStackPluginOptions {
|
|
4
|
+
routesDir?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function TanStackPlugin(options?: TanStackPluginOptions): FrameworkPlugin;
|
|
7
|
+
|
|
8
|
+
export { TanStackPlugin, type TanStackPluginOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import fg from "fast-glob";
|
|
5
|
+
function TanStackPlugin(options = {}) {
|
|
6
|
+
const opts = { routesDir: "src/routes", ...options };
|
|
7
|
+
return {
|
|
8
|
+
id: "tanstack-router",
|
|
9
|
+
name: "TanStack Router",
|
|
10
|
+
version: "0.1.0",
|
|
11
|
+
capabilities: {
|
|
12
|
+
supportsAppRouter: false,
|
|
13
|
+
supportsPagesRouter: false,
|
|
14
|
+
supportsMiddleware: false,
|
|
15
|
+
supportsApiRoutes: false,
|
|
16
|
+
supportsI18n: false,
|
|
17
|
+
supportsIncrementalAnalysis: true
|
|
18
|
+
},
|
|
19
|
+
async detect(ctx) {
|
|
20
|
+
const pkgPath = join(ctx.root, "package.json");
|
|
21
|
+
if (!existsSync(pkgPath)) return false;
|
|
22
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
23
|
+
return Boolean(pkg.dependencies?.["@tanstack/react-router"]);
|
|
24
|
+
},
|
|
25
|
+
async configure(_ctx) {
|
|
26
|
+
return { routesDir: opts.routesDir };
|
|
27
|
+
},
|
|
28
|
+
async *discoverRoutes(ctx) {
|
|
29
|
+
const routesPath = join(ctx.root, opts.routesDir);
|
|
30
|
+
if (!existsSync(routesPath)) return;
|
|
31
|
+
const files = await fg(["**/*.{tsx,ts}"], {
|
|
32
|
+
cwd: routesPath,
|
|
33
|
+
absolute: true,
|
|
34
|
+
ignore: ["**/*.test.*"]
|
|
35
|
+
});
|
|
36
|
+
for (const filePath of files) {
|
|
37
|
+
const rel = filePath.replace(routesPath, "").replace(/\\/g, "/");
|
|
38
|
+
const urlPath = rel.replace(/\.(tsx|ts)$/, "").replace(/\/index$/, "").replace(/^\//, "") || "/";
|
|
39
|
+
yield {
|
|
40
|
+
id: `tanstack:${urlPath}`,
|
|
41
|
+
type: "route",
|
|
42
|
+
filePath,
|
|
43
|
+
urlPath: urlPath.startsWith("/") ? urlPath : `/${urlPath}`,
|
|
44
|
+
segment: urlPath.split("/").pop() ?? "",
|
|
45
|
+
isDynamic: urlPath.includes("$"),
|
|
46
|
+
isCatchAll: urlPath.includes("_splat"),
|
|
47
|
+
isOptionalCatchAll: false,
|
|
48
|
+
isParallelSlot: false,
|
|
49
|
+
isIntercepted: false,
|
|
50
|
+
isRouteGroup: false,
|
|
51
|
+
tags: ["tanstack-router"]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async analyzeFile(file, ctx) {
|
|
56
|
+
const edges = [];
|
|
57
|
+
const sourceId = [...ctx.routes.values()].find((r) => r.filePath === file.path)?.id ?? "";
|
|
58
|
+
for (const link of file.jsxLinks) {
|
|
59
|
+
edges.push({
|
|
60
|
+
sourceId,
|
|
61
|
+
targetPath: link.destination.kind === "static" ? link.destination.path : void 0,
|
|
62
|
+
type: "navigation",
|
|
63
|
+
source: "Link",
|
|
64
|
+
isExternal: link.destination.kind === "external",
|
|
65
|
+
conditions: link.conditions,
|
|
66
|
+
loc: link.loc
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
for (const call of file.navigationCalls) {
|
|
70
|
+
if (call.callee.includes("navigate")) {
|
|
71
|
+
edges.push({
|
|
72
|
+
sourceId,
|
|
73
|
+
targetPath: call.destination.kind === "static" ? call.destination.path : void 0,
|
|
74
|
+
type: "navigation",
|
|
75
|
+
source: "router.push",
|
|
76
|
+
method: call.method,
|
|
77
|
+
isExternal: false,
|
|
78
|
+
conditions: call.conditions,
|
|
79
|
+
loc: call.loc
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
filePath: file.path,
|
|
85
|
+
edges,
|
|
86
|
+
conditions: [],
|
|
87
|
+
tags: ["tanstack-router"],
|
|
88
|
+
diagnostics: []
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
async enrichGraph(_graph, _ctx) {
|
|
92
|
+
},
|
|
93
|
+
async runDiagnostics(_graph) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
TanStackPlugin
|
|
100
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@route-intelligence/tanstack",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "TanStack Router plugin for Route Intelligence",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"test": "vitest run --passWithNoTests"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@route-intelligence/shared": "*",
|
|
25
|
+
"fast-glob": "^3.3.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@route-intelligence/tsconfig": "*",
|
|
29
|
+
"@types/node": "^22.15.32",
|
|
30
|
+
"tsup": "^8.4.0",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"vitest": "^3.2.4"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|