@bleedingdev/modern-js-plugin-tanstack 3.9.3-ultramodern.1 → 3.9.3-ultramodern.11
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.
|
@@ -31,24 +31,52 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
describeRouteTree: ()=>describeRouteTree
|
|
32
32
|
});
|
|
33
33
|
const paths_js_namespaceObject = require("../runtime/routeTree/paths.js");
|
|
34
|
+
const isPathless = (route)=>0 === (route.path ?? '').length && true !== route.index;
|
|
35
|
+
const toLocationPath = (route)=>true === route.index ? '/' : (0, paths_js_namespaceObject.toTanstackPath)(route.path || '');
|
|
36
|
+
const joinPath = (parent, path)=>`${parent}/${path}`.replace(/\/{2,}/g, '/');
|
|
37
|
+
function collectFullPaths(routes, parentPath, fullPaths) {
|
|
38
|
+
for (const route of routes){
|
|
39
|
+
let fullPath = parentPath;
|
|
40
|
+
if (!isPathless(route)) {
|
|
41
|
+
fullPath = joinPath(parentPath, toLocationPath(route));
|
|
42
|
+
fullPaths.push(fullPath);
|
|
43
|
+
}
|
|
44
|
+
collectFullPaths(route.children ?? [], fullPath, fullPaths);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const isPrefixIndex = (fullPath, fullPaths)=>!fullPath.endsWith('/') && fullPaths.some((other)=>other.startsWith(`${fullPath}/`) && other.length > fullPath.length + 1);
|
|
34
48
|
function describeRouteTree(routes) {
|
|
35
49
|
const root = routes.find((route)=>true === route.isRoot || '/' === route.path && true !== route.index);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
const topLevel = void 0 !== root ? [
|
|
51
|
+
...root.children ?? [],
|
|
52
|
+
...routes.filter((route)=>route !== root)
|
|
53
|
+
] : routes;
|
|
54
|
+
const fullPaths = [];
|
|
55
|
+
collectFullPaths(topLevel, '', fullPaths);
|
|
56
|
+
const describe = (parentPath)=>(route, index)=>{
|
|
57
|
+
const children = route.children ?? [];
|
|
58
|
+
if (isPathless(route)) return {
|
|
59
|
+
source: route,
|
|
60
|
+
location: {
|
|
61
|
+
id: route.id || route.file || `pathless-${index}`
|
|
62
|
+
},
|
|
63
|
+
hasSplat: false,
|
|
64
|
+
children: children.map(describe(parentPath))
|
|
65
|
+
};
|
|
66
|
+
const path = toLocationPath(route);
|
|
67
|
+
const fullPath = joinPath(parentPath, path);
|
|
68
|
+
return {
|
|
69
|
+
source: route,
|
|
70
|
+
location: {
|
|
71
|
+
path: 0 === children.length && isPrefixIndex(fullPath, fullPaths) ? `${path}/` : path
|
|
72
|
+
},
|
|
73
|
+
hasSplat: Boolean(route.path?.includes('*')),
|
|
74
|
+
children: children.map(describe(fullPath))
|
|
75
|
+
};
|
|
76
|
+
};
|
|
46
77
|
return {
|
|
47
78
|
root,
|
|
48
|
-
children: (
|
|
49
|
-
...root.children ?? [],
|
|
50
|
-
...routes.filter((route)=>route !== root)
|
|
51
|
-
] : routes).map(describe)
|
|
79
|
+
children: topLevel.map(describe(''))
|
|
52
80
|
};
|
|
53
81
|
}
|
|
54
82
|
exports.describeRouteTree = __webpack_exports__.describeRouteTree;
|
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
import { toTanstackPath } from "../runtime/routeTree/paths.mjs";
|
|
2
|
+
const isPathless = (route)=>0 === (route.path ?? '').length && true !== route.index;
|
|
3
|
+
const toLocationPath = (route)=>true === route.index ? '/' : toTanstackPath(route.path || '');
|
|
4
|
+
const joinPath = (parent, path)=>`${parent}/${path}`.replace(/\/{2,}/g, '/');
|
|
5
|
+
function collectFullPaths(routes, parentPath, fullPaths) {
|
|
6
|
+
for (const route of routes){
|
|
7
|
+
let fullPath = parentPath;
|
|
8
|
+
if (!isPathless(route)) {
|
|
9
|
+
fullPath = joinPath(parentPath, toLocationPath(route));
|
|
10
|
+
fullPaths.push(fullPath);
|
|
11
|
+
}
|
|
12
|
+
collectFullPaths(route.children ?? [], fullPath, fullPaths);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const isPrefixIndex = (fullPath, fullPaths)=>!fullPath.endsWith('/') && fullPaths.some((other)=>other.startsWith(`${fullPath}/`) && other.length > fullPath.length + 1);
|
|
2
16
|
function describeRouteTree(routes) {
|
|
3
17
|
const root = routes.find((route)=>true === route.isRoot || '/' === route.path && true !== route.index);
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
const topLevel = void 0 !== root ? [
|
|
19
|
+
...root.children ?? [],
|
|
20
|
+
...routes.filter((route)=>route !== root)
|
|
21
|
+
] : routes;
|
|
22
|
+
const fullPaths = [];
|
|
23
|
+
collectFullPaths(topLevel, '', fullPaths);
|
|
24
|
+
const describe = (parentPath)=>(route, index)=>{
|
|
25
|
+
const children = route.children ?? [];
|
|
26
|
+
if (isPathless(route)) return {
|
|
27
|
+
source: route,
|
|
28
|
+
location: {
|
|
29
|
+
id: route.id || route.file || `pathless-${index}`
|
|
30
|
+
},
|
|
31
|
+
hasSplat: false,
|
|
32
|
+
children: children.map(describe(parentPath))
|
|
33
|
+
};
|
|
34
|
+
const path = toLocationPath(route);
|
|
35
|
+
const fullPath = joinPath(parentPath, path);
|
|
36
|
+
return {
|
|
37
|
+
source: route,
|
|
38
|
+
location: {
|
|
39
|
+
path: 0 === children.length && isPrefixIndex(fullPath, fullPaths) ? `${path}/` : path
|
|
40
|
+
},
|
|
41
|
+
hasSplat: Boolean(route.path?.includes('*')),
|
|
42
|
+
children: children.map(describe(fullPath))
|
|
43
|
+
};
|
|
44
|
+
};
|
|
14
45
|
return {
|
|
15
46
|
root,
|
|
16
|
-
children: (
|
|
17
|
-
...root.children ?? [],
|
|
18
|
-
...routes.filter((route)=>route !== root)
|
|
19
|
-
] : routes).map(describe)
|
|
47
|
+
children: topLevel.map(describe(''))
|
|
20
48
|
};
|
|
21
49
|
}
|
|
22
50
|
export { describeRouteTree };
|
|
@@ -1,23 +1,51 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { toTanstackPath } from "../runtime/routeTree/paths.mjs";
|
|
3
|
+
const isPathless = (route)=>0 === (route.path ?? '').length && true !== route.index;
|
|
4
|
+
const toLocationPath = (route)=>true === route.index ? '/' : toTanstackPath(route.path || '');
|
|
5
|
+
const joinPath = (parent, path)=>`${parent}/${path}`.replace(/\/{2,}/g, '/');
|
|
6
|
+
function collectFullPaths(routes, parentPath, fullPaths) {
|
|
7
|
+
for (const route of routes){
|
|
8
|
+
let fullPath = parentPath;
|
|
9
|
+
if (!isPathless(route)) {
|
|
10
|
+
fullPath = joinPath(parentPath, toLocationPath(route));
|
|
11
|
+
fullPaths.push(fullPath);
|
|
12
|
+
}
|
|
13
|
+
collectFullPaths(route.children ?? [], fullPath, fullPaths);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const isPrefixIndex = (fullPath, fullPaths)=>!fullPath.endsWith('/') && fullPaths.some((other)=>other.startsWith(`${fullPath}/`) && other.length > fullPath.length + 1);
|
|
3
17
|
function describeRouteTree(routes) {
|
|
4
18
|
const root = routes.find((route)=>true === route.isRoot || '/' === route.path && true !== route.index);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
const topLevel = void 0 !== root ? [
|
|
20
|
+
...root.children ?? [],
|
|
21
|
+
...routes.filter((route)=>route !== root)
|
|
22
|
+
] : routes;
|
|
23
|
+
const fullPaths = [];
|
|
24
|
+
collectFullPaths(topLevel, '', fullPaths);
|
|
25
|
+
const describe = (parentPath)=>(route, index)=>{
|
|
26
|
+
const children = route.children ?? [];
|
|
27
|
+
if (isPathless(route)) return {
|
|
28
|
+
source: route,
|
|
29
|
+
location: {
|
|
30
|
+
id: route.id || route.file || `pathless-${index}`
|
|
31
|
+
},
|
|
32
|
+
hasSplat: false,
|
|
33
|
+
children: children.map(describe(parentPath))
|
|
34
|
+
};
|
|
35
|
+
const path = toLocationPath(route);
|
|
36
|
+
const fullPath = joinPath(parentPath, path);
|
|
37
|
+
return {
|
|
38
|
+
source: route,
|
|
39
|
+
location: {
|
|
40
|
+
path: 0 === children.length && isPrefixIndex(fullPath, fullPaths) ? `${path}/` : path
|
|
41
|
+
},
|
|
42
|
+
hasSplat: Boolean(route.path?.includes('*')),
|
|
43
|
+
children: children.map(describe(fullPath))
|
|
44
|
+
};
|
|
45
|
+
};
|
|
15
46
|
return {
|
|
16
47
|
root,
|
|
17
|
-
children: (
|
|
18
|
-
...root.children ?? [],
|
|
19
|
-
...routes.filter((route)=>route !== root)
|
|
20
|
-
] : routes).map(describe)
|
|
48
|
+
children: topLevel.map(describe(''))
|
|
21
49
|
};
|
|
22
50
|
}
|
|
23
51
|
export { describeRouteTree };
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modern.js",
|
|
19
19
|
"tanstack-router"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.9.3-ultramodern.
|
|
21
|
+
"version": "3.9.3-ultramodern.11",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -94,21 +94,21 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.3-ultramodern.
|
|
98
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.3-ultramodern.
|
|
99
|
-
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.3-ultramodern.
|
|
100
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.3-ultramodern.
|
|
101
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.
|
|
102
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.3-ultramodern.
|
|
97
|
+
"@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.3-ultramodern.11",
|
|
98
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.3-ultramodern.11",
|
|
99
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.3-ultramodern.11",
|
|
100
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.3-ultramodern.11",
|
|
101
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.11",
|
|
102
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.3-ultramodern.11",
|
|
103
103
|
"@swc/helpers": "^0.5.23",
|
|
104
|
-
"@tanstack/react-router": "1.170.
|
|
105
|
-
"@tanstack/router-core": "1.171.
|
|
104
|
+
"@tanstack/react-router": "1.170.44",
|
|
105
|
+
"@tanstack/router-core": "1.171.37"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@modern-js/app-tools": "3.9.3-ultramodern.
|
|
109
|
-
"@modern-js/runtime": "3.9.3-ultramodern.
|
|
110
|
-
"react": "^19.
|
|
111
|
-
"react-dom": "^19.
|
|
108
|
+
"@modern-js/app-tools": "3.9.3-ultramodern.11",
|
|
109
|
+
"@modern-js/runtime": "3.9.3-ultramodern.11",
|
|
110
|
+
"react": "^19.3.1",
|
|
111
|
+
"react-dom": "^19.3.1",
|
|
112
112
|
"react-server-dom-rspack": "0.1.0"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
@@ -117,19 +117,19 @@
|
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.
|
|
121
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.3-ultramodern.
|
|
122
|
-
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.3-ultramodern.
|
|
120
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.11",
|
|
121
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.3-ultramodern.11",
|
|
122
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.3-ultramodern.11",
|
|
123
123
|
"@rslib/core": "1.0.3",
|
|
124
124
|
"@scripts/rstest-config": "2.66.0",
|
|
125
|
-
"@tanstack/history": "1.162.
|
|
125
|
+
"@tanstack/history": "1.162.5",
|
|
126
126
|
"@testing-library/react": "^16.3.3",
|
|
127
127
|
"@tsconfig/strictest": "2.0.8",
|
|
128
|
-
"@types/node": "^26.6.
|
|
128
|
+
"@types/node": "^26.6.5",
|
|
129
129
|
"@types/react": "^19.3.0",
|
|
130
130
|
"@types/react-dom": "^19.3.0",
|
|
131
|
-
"react": "^19.3.
|
|
132
|
-
"react-dom": "^19.3.
|
|
131
|
+
"react": "^19.3.1",
|
|
132
|
+
"react-dom": "^19.3.1",
|
|
133
133
|
"react-server-dom-rspack": "0.1.0"
|
|
134
134
|
},
|
|
135
135
|
"sideEffects": [
|
|
@@ -17,30 +17,86 @@ export type RouteDescriptor<T extends RouteShape> = {
|
|
|
17
17
|
children: RouteDescriptor<T>[];
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const isPathless = (route: RouteShape) =>
|
|
21
|
+
(route.path ?? '').length === 0 && route.index !== true;
|
|
22
|
+
|
|
23
|
+
const toLocationPath = (route: RouteShape) =>
|
|
24
|
+
route.index === true ? '/' : toTanstackPath(route.path || '');
|
|
25
|
+
|
|
26
|
+
const joinPath = (parent: string, path: string) =>
|
|
27
|
+
`${parent}/${path}`.replace(/\/{2,}/g, '/');
|
|
28
|
+
|
|
29
|
+
function collectFullPaths(
|
|
30
|
+
routes: RouteShape[],
|
|
31
|
+
parentPath: string,
|
|
32
|
+
fullPaths: string[],
|
|
33
|
+
) {
|
|
34
|
+
for (const route of routes) {
|
|
35
|
+
let fullPath = parentPath;
|
|
36
|
+
if (!isPathless(route)) {
|
|
37
|
+
fullPath = joinPath(parentPath, toLocationPath(route));
|
|
38
|
+
fullPaths.push(fullPath);
|
|
39
|
+
}
|
|
40
|
+
collectFullPaths(route.children ?? [], fullPath, fullPaths);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Modern flattens layout-less directories into prefixed routes, so
|
|
46
|
+
* `[lang]/page.tsx` and `[lang]/$.tsx` become the routes `:lang` and
|
|
47
|
+
* `:lang/*`. TanStack matches `/en` to the splat unless the plain leaf is
|
|
48
|
+
* declared as the index of that prefix (`$lang/`). A leaf is that index when
|
|
49
|
+
* any other route lives below its full path, including routes nested under
|
|
50
|
+
* pathless layouts, because TanStack matches across those layouts.
|
|
51
|
+
*/
|
|
52
|
+
const isPrefixIndex = (fullPath: string, fullPaths: string[]) =>
|
|
53
|
+
!fullPath.endsWith('/') &&
|
|
54
|
+
fullPaths.some(
|
|
55
|
+
other =>
|
|
56
|
+
other.startsWith(`${fullPath}/`) && other.length > fullPath.length + 1,
|
|
57
|
+
);
|
|
58
|
+
|
|
20
59
|
export function describeRouteTree<T extends RouteShape>(routes: T[]) {
|
|
21
60
|
const root = routes.find(
|
|
22
61
|
route =>
|
|
23
62
|
route.isRoot === true || (route.path === '/' && route.index !== true),
|
|
24
63
|
);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
location:
|
|
28
|
-
(route.path ?? '').length === 0 && route.index !== true
|
|
29
|
-
? { id: route.id || route.file || `pathless-${index}` }
|
|
30
|
-
: {
|
|
31
|
-
path: route.index === true ? '/' : toTanstackPath(route.path || ''),
|
|
32
|
-
},
|
|
33
|
-
hasSplat: Boolean(route.path?.includes('*')),
|
|
34
|
-
children: ((route.children ?? []) as T[]).map(describe),
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
root,
|
|
38
|
-
children: (root !== undefined
|
|
64
|
+
const topLevel =
|
|
65
|
+
root !== undefined
|
|
39
66
|
? [
|
|
40
67
|
...((root.children ?? []) as T[]),
|
|
41
68
|
...routes.filter(route => route !== root),
|
|
42
69
|
]
|
|
43
|
-
: routes
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
: routes;
|
|
71
|
+
const fullPaths: string[] = [];
|
|
72
|
+
collectFullPaths(topLevel, '', fullPaths);
|
|
73
|
+
|
|
74
|
+
const describe =
|
|
75
|
+
(parentPath: string) =>
|
|
76
|
+
(route: T, index: number): RouteDescriptor<T> => {
|
|
77
|
+
const children = (route.children ?? []) as T[];
|
|
78
|
+
if (isPathless(route)) {
|
|
79
|
+
return {
|
|
80
|
+
source: route,
|
|
81
|
+
location: { id: route.id || route.file || `pathless-${index}` },
|
|
82
|
+
hasSplat: false,
|
|
83
|
+
children: children.map(describe(parentPath)),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const path = toLocationPath(route);
|
|
87
|
+
const fullPath = joinPath(parentPath, path);
|
|
88
|
+
return {
|
|
89
|
+
source: route,
|
|
90
|
+
location: {
|
|
91
|
+
path:
|
|
92
|
+
children.length === 0 && isPrefixIndex(fullPath, fullPaths)
|
|
93
|
+
? `${path}/`
|
|
94
|
+
: path,
|
|
95
|
+
},
|
|
96
|
+
hasSplat: Boolean(route.path?.includes('*')),
|
|
97
|
+
children: children.map(describe(fullPath)),
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return { root, children: topLevel.map(describe('')) };
|
|
46
102
|
}
|