dinou 9.3.0 → 10.0.1
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/CHANGELOG.md +196 -0
- package/README.md +157 -132
- package/dinou/adapters/bun.js +34 -5
- package/dinou/adapters/cloudflare.js +110 -17
- package/dinou/adapters/deno.js +46 -8
- package/dinou/adapters/netlify.js +86 -50
- package/dinou/adapters/node.js +8 -0
- package/dinou/assets.d.ts +32 -5
- package/dinou/bun/build.js +190 -106
- package/dinou/cli.js +992 -532
- package/dinou/cloudflare/build.js +187 -106
- package/dinou/compiled/autoprefixer/index.js +509 -517
- package/dinou/compiled/babel-core/index.js +738 -716
- package/dinou/compiled/babel-generator/index.js +341 -299
- package/dinou/compiled/babel-loader/index.js +766 -744
- package/dinou/compiled/babel-parser/index.js +2 -2
- package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
- package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
- package/dinou/compiled/babel-preset-react/index.js +752 -730
- package/dinou/compiled/babel-preset-typescript/index.js +738 -716
- package/dinou/compiled/babel-traverse/index.js +463 -433
- package/dinou/compiled/babel-types/index.js +176 -176
- package/dinou/compiled/chokidar/index.js +4 -4
- package/dinou/compiled/commander/index.js +15 -15
- package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
- package/dinou/compiled/css-loader/index.js +289 -289
- package/dinou/compiled/css-loader/runtime/api.js +85 -0
- package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
- package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
- package/dinou/compiled/css-loader/runtime/package.json +3 -0
- package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
- package/dinou/compiled/fast-glob/index.js +5810 -0
- package/dinou/compiled/generic-names/index.js +16 -16
- package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
- package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
- package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
- package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
- package/dinou/compiled/postcss/index.js +83 -83
- package/dinou/compiled/postcss-import/index.js +147 -117
- package/dinou/compiled/postcss-modules/index.js +216 -216
- package/dinou/compiled/resolve/index.js +1224 -0
- package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
- package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
- package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
- package/dinou/compiled/rollup-plugin-json/index.js +22 -18
- package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
- package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
- package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
- package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
- package/dinou/compiled/vendors-manifest.json +59 -83
- package/dinou/core/asset-extensions.js +482 -33
- package/dinou/core/bailout-proxy.js +21 -2
- package/dinou/core/build-static-pages.js +523 -371
- package/dinou/core/builtin-asset-extensions.js +63 -0
- package/dinou/core/cache-revalidate.js +449 -256
- package/dinou/core/cache-slot.js +289 -79
- package/dinou/core/client-webpack.jsx +470 -39
- package/dinou/core/client.jsx +402 -39
- package/dinou/core/config.js +3 -0
- package/dinou/core/copy-static-dirs.js +98 -0
- package/dinou/core/createScopedName.js +22 -4
- package/dinou/core/dinou-paths.js +1 -1
- package/dinou/core/discover-layouts.js +200 -0
- package/dinou/core/edge-ssr.js +1 -1
- package/dinou/core/ensure-vendor-mode.js +78 -19
- package/dinou/core/env.js +544 -0
- package/dinou/core/export-static.js +41 -9
- package/dinou/core/generate-route-types.js +989 -95
- package/dinou/core/generate-static-rsc.js +5 -6
- package/dinou/core/generate-static.js +45 -6
- package/dinou/core/get-abs-path-with-ext.js +217 -75
- package/dinou/core/get-asset-from-manifest.js +19 -8
- package/dinou/core/get-error-jsx.js +4 -5
- package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
- package/dinou/core/get-jsx.js +220 -53
- package/dinou/core/handler.js +1647 -466
- package/dinou/core/import-module.js +7 -0
- package/dinou/core/layout-functions.js +72 -13
- package/dinou/core/link.jsx +34 -6
- package/dinou/core/load-dinou-config.js +520 -89
- package/dinou/core/manifest-provider.js +4 -14
- package/dinou/core/navigation-utils.js +141 -3
- package/dinou/core/navigation.js +134 -50
- package/dinou/core/node-middleware-runner.js +165 -0
- package/dinou/core/postcss-pipeline.js +236 -0
- package/dinou/core/ppr-context.js +114 -22
- package/dinou/core/ppr-runtime.js +391 -127
- package/dinou/core/redirect.jsx +1 -1
- package/dinou/core/render-jsx-to-client-jsx.js +216 -48
- package/dinou/core/request-context.js +59 -3
- package/dinou/core/resolve-contextual-dinou.js +523 -0
- package/dinou/core/resolve-setup-files.js +85 -27
- package/dinou/core/revalidating.js +10 -2
- package/dinou/core/route-generator.js +6 -2
- package/dinou/core/rsc-renderer.js +4 -1
- package/dinou/core/run-ssg.js +6 -0
- package/dinou/core/runtime-env.js +265 -0
- package/dinou/core/server-css-modules-plugin.js +155 -0
- package/dinou/core/server-function-proxy-webpack.js +27 -2
- package/dinou/core/server-function-proxy.js +27 -2
- package/dinou/core/slot.js +47 -2
- package/dinou/core/static-assets.js +503 -0
- package/dinou/core/storage-adapter.js +452 -24
- package/dinou/core/transform-server-functions.js +272 -24
- package/dinou/core/tsconfig-aliases.js +964 -0
- package/dinou/core/uneject.js +640 -0
- package/dinou/core/url-resolver.js +1 -1
- package/dinou/core/vfs.js +11 -2
- package/dinou/css.d.ts +4 -1
- package/dinou/deno/build.js +205 -153
- package/dinou/deno/seed-kv.js +4 -0
- package/dinou/env.d.ts +22 -2
- package/dinou/esbuild/build.js +40 -50
- package/dinou/esbuild/dev.js +33 -7
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
- package/dinou/esbuild/helpers-esbuild/write.js +13 -3
- package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
- package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
- package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
- package/dinou/index.d.ts +1028 -88
- package/dinou/node/build.js +138 -74
- package/dinou/node/bundle-dual-engine.js +393 -131
- package/dinou/node/dev.js +1005 -275
- package/dinou/package.json +11 -34
- package/dinou/rollup/postcss.config.js +3 -4
- package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
- package/dinou/rollup/rollup.config.js +174 -101
- package/dinou/scripts/build-vendors.js +123 -33
- package/dinou/server.d.ts +126 -15
- package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
- package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
- package/dinou/webpack/loaders/server-functions-loader.js +1 -1
- package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
- package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
- package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
- package/dinou/webpack/postcss.config.js +3 -4
- package/dinou/webpack/webpack.config.js +408 -132
- package/eject.js +6 -224
- package/package.json +7 -9
- package/dinou/compiled/cross-env/index.js +0 -661
- package/dinou/compiled/dotenv/index.js +0 -375
- package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
- package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
- package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
- package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
- package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
|
@@ -9,10 +9,71 @@ function safeDecode(val) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function sortDirEntries(entries) {
|
|
13
|
+
return [...entries].sort((a, b) =>
|
|
14
|
+
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isGroupDir(name) {
|
|
19
|
+
return name.startsWith("(") && name.endsWith(")");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isOptionalCatchAllDir(name) {
|
|
23
|
+
return name.startsWith("[[...") && name.endsWith("]]");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isCatchAllDir(name) {
|
|
27
|
+
return !isOptionalCatchAllDir(name) && name.startsWith("[...") && name.endsWith("]");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isOptionalSingleDynamicDir(name) {
|
|
31
|
+
return !isOptionalCatchAllDir(name) && name.startsWith("[[") && name.endsWith("]]");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isSingleDynamicDir(name) {
|
|
35
|
+
return (
|
|
36
|
+
!isCatchAllDir(name) &&
|
|
37
|
+
!isOptionalSingleDynamicDir(name) &&
|
|
38
|
+
!isOptionalCatchAllDir(name) &&
|
|
39
|
+
name.startsWith("[") &&
|
|
40
|
+
name.endsWith("]")
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function findCandidateFile(dirPath, fileName, withExtension, possibleExtensions) {
|
|
45
|
+
if (withExtension) {
|
|
46
|
+
for (const ext of possibleExtensions) {
|
|
47
|
+
const candidatePath = path.join(dirPath, `${fileName}${ext}`);
|
|
48
|
+
if (existsSync(candidatePath)) {
|
|
49
|
+
return candidatePath;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const candidatePath = path.join(dirPath, fileName);
|
|
55
|
+
return existsSync(candidatePath) ? candidatePath : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function collectGroupChains(dir, prefixGroups = []) {
|
|
59
|
+
const entries = sortDirEntries(readdirSync(dir, { withFileTypes: true }));
|
|
60
|
+
const dirEntries = entries.filter(
|
|
61
|
+
(e) => e.isDirectory() && !e.name.startsWith("_") && !e.name.startsWith("@")
|
|
62
|
+
);
|
|
63
|
+
const chains = [{ targetDir: dir, groupDirs: prefixGroups, dirEntries }];
|
|
64
|
+
for (const entry of dirEntries) {
|
|
65
|
+
if (isGroupDir(entry.name)) {
|
|
66
|
+
const groupPath = path.join(dir, entry.name);
|
|
67
|
+
chains.push(...collectGroupChains(groupPath, [...prefixGroups, groupPath]));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return chains;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getSlots(currentPath, reqSegments, query, dParams = {}) {
|
|
13
74
|
let slots = {};
|
|
14
75
|
|
|
15
|
-
const entries = readdirSync(currentPath, { withFileTypes: true });
|
|
76
|
+
const entries = sortDirEntries(readdirSync(currentPath, { withFileTypes: true }));
|
|
16
77
|
|
|
17
78
|
for (const entry of entries) {
|
|
18
79
|
if (!entry.isDirectory() || entry.name.startsWith("_")) continue;
|
|
@@ -26,7 +87,8 @@ function getSlots(currentPath, reqSegments, query) {
|
|
|
26
87
|
true,
|
|
27
88
|
true,
|
|
28
89
|
undefined,
|
|
29
|
-
reqSegments.length
|
|
90
|
+
reqSegments.length,
|
|
91
|
+
dParams
|
|
30
92
|
);
|
|
31
93
|
|
|
32
94
|
if (slotPath) {
|
|
@@ -36,10 +98,10 @@ function getSlots(currentPath, reqSegments, query) {
|
|
|
36
98
|
slotParams,
|
|
37
99
|
};
|
|
38
100
|
}
|
|
39
|
-
} else if (
|
|
101
|
+
} else if (isGroupDir(entry.name)) {
|
|
40
102
|
const groupPath = path.join(currentPath, entry.name);
|
|
41
103
|
|
|
42
|
-
const nestedSlots = getSlots(groupPath, reqSegments, query);
|
|
104
|
+
const nestedSlots = getSlots(groupPath, reqSegments, query, dParams);
|
|
43
105
|
|
|
44
106
|
slots = { ...slots, ...nestedSlots };
|
|
45
107
|
}
|
|
@@ -48,378 +110,539 @@ function getSlots(currentPath, reqSegments, query) {
|
|
|
48
110
|
return slots;
|
|
49
111
|
}
|
|
50
112
|
|
|
51
|
-
function
|
|
113
|
+
function matchRouteTree(
|
|
52
114
|
reqSegments,
|
|
53
115
|
query,
|
|
54
116
|
currentPath,
|
|
55
|
-
fileName
|
|
56
|
-
withExtension
|
|
57
|
-
finalDestination
|
|
58
|
-
lastFound
|
|
59
|
-
index
|
|
60
|
-
dParams
|
|
61
|
-
accumulative
|
|
62
|
-
accumulate
|
|
63
|
-
isFound
|
|
64
|
-
possibleExtensions
|
|
117
|
+
fileName,
|
|
118
|
+
withExtension,
|
|
119
|
+
finalDestination,
|
|
120
|
+
lastFound,
|
|
121
|
+
index,
|
|
122
|
+
dParams,
|
|
123
|
+
accumulative,
|
|
124
|
+
accumulate,
|
|
125
|
+
isFound,
|
|
126
|
+
possibleExtensions,
|
|
127
|
+
lineage,
|
|
128
|
+
maxDepthRef
|
|
65
129
|
) {
|
|
130
|
+
if (index > maxDepthRef.value) {
|
|
131
|
+
maxDepthRef.value = index;
|
|
132
|
+
}
|
|
133
|
+
lineage.push({ dir: currentPath, dParams, index });
|
|
134
|
+
|
|
66
135
|
let foundInCurrentPath;
|
|
67
136
|
if (index > reqSegments.length - 1 || !finalDestination) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
const candidatePath = path.join(currentPath, fileName);
|
|
90
|
-
if (existsSync(candidatePath)) {
|
|
91
|
-
if (index > reqSegments.length - 1) {
|
|
92
|
-
isFound.value = true;
|
|
93
|
-
if (!accumulative) return [candidatePath, dParams];
|
|
94
|
-
const slots = getSlots(currentPath, reqSegments, query);
|
|
137
|
+
const candidatePath = findCandidateFile(
|
|
138
|
+
currentPath,
|
|
139
|
+
fileName,
|
|
140
|
+
withExtension,
|
|
141
|
+
possibleExtensions
|
|
142
|
+
);
|
|
143
|
+
if (candidatePath) {
|
|
144
|
+
if (index > reqSegments.length - 1) {
|
|
145
|
+
isFound.value = true;
|
|
146
|
+
if (!accumulative) return [candidatePath, dParams];
|
|
147
|
+
const slots = getSlots(currentPath, reqSegments, query, dParams);
|
|
148
|
+
accumulate.push([candidatePath, dParams, slots]);
|
|
149
|
+
if (finalDestination) return accumulate;
|
|
150
|
+
} else {
|
|
151
|
+
if (accumulative) {
|
|
152
|
+
const slots = getSlots(currentPath, reqSegments, query, dParams);
|
|
95
153
|
accumulate.push([candidatePath, dParams, slots]);
|
|
96
|
-
if (finalDestination) return accumulate;
|
|
97
154
|
} else {
|
|
98
|
-
|
|
99
|
-
const slots = getSlots(currentPath, reqSegments, query);
|
|
100
|
-
accumulate.push([candidatePath, dParams, slots]);
|
|
101
|
-
} else {
|
|
102
|
-
foundInCurrentPath = candidatePath;
|
|
103
|
-
}
|
|
155
|
+
foundInCurrentPath = candidatePath;
|
|
104
156
|
}
|
|
105
157
|
}
|
|
106
158
|
}
|
|
159
|
+
|
|
107
160
|
if (index > reqSegments.length - 1) {
|
|
108
|
-
const entries =
|
|
161
|
+
const entries = sortDirEntries(
|
|
162
|
+
readdirSync(currentPath, { withFileTypes: true })
|
|
163
|
+
).filter(
|
|
164
|
+
(e) =>
|
|
165
|
+
e.isDirectory() && !e.name.startsWith("_") && !e.name.startsWith("@")
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
let fallbackParams;
|
|
169
|
+
|
|
170
|
+
// 1. Zero-segment route groups: (group)
|
|
171
|
+
for (const entry of entries) {
|
|
172
|
+
if (!isGroupDir(entry.name)) continue;
|
|
173
|
+
const groupPath = path.join(currentPath, entry.name);
|
|
174
|
+
const branchAccumulate = [...accumulate];
|
|
175
|
+
const branchLineage = [...lineage];
|
|
176
|
+
const branchIsFound = { value: false };
|
|
177
|
+
const branchMaxDepth = { value: maxDepthRef.value };
|
|
178
|
+
const result = matchRouteTree(
|
|
179
|
+
reqSegments,
|
|
180
|
+
query,
|
|
181
|
+
groupPath,
|
|
182
|
+
fileName,
|
|
183
|
+
withExtension,
|
|
184
|
+
finalDestination,
|
|
185
|
+
foundInCurrentPath ?? lastFound,
|
|
186
|
+
index,
|
|
187
|
+
dParams,
|
|
188
|
+
accumulative,
|
|
189
|
+
branchAccumulate,
|
|
190
|
+
branchIsFound,
|
|
191
|
+
possibleExtensions,
|
|
192
|
+
branchLineage,
|
|
193
|
+
branchMaxDepth
|
|
194
|
+
);
|
|
195
|
+
if (branchIsFound.value) {
|
|
196
|
+
isFound.value = true;
|
|
197
|
+
accumulate.splice(0, accumulate.length, ...branchAccumulate);
|
|
198
|
+
lineage.splice(0, lineage.length, ...branchLineage);
|
|
199
|
+
return accumulative ? accumulate : result;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 2. Optional single dynamic segment: [[param]]
|
|
109
204
|
for (const entry of entries) {
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return [candidatePath, newParams];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
const candidatePath = path.join(dynamicPath, fileName);
|
|
140
|
-
if (existsSync(candidatePath)) {
|
|
141
|
-
isFound.value = true;
|
|
142
|
-
if (accumulative) {
|
|
143
|
-
const slots = getSlots(dynamicPath, reqSegments, query);
|
|
144
|
-
accumulate.push([candidatePath, newParams, slots]);
|
|
145
|
-
return accumulate;
|
|
146
|
-
}
|
|
147
|
-
return [candidatePath, newParams];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (accumulative) return accumulate;
|
|
151
|
-
return finalDestination
|
|
152
|
-
? []
|
|
153
|
-
: [foundInCurrentPath ?? lastFound, newParams];
|
|
154
|
-
} else if (entry.name.startsWith("[[") && entry.name.endsWith("]]")) {
|
|
155
|
-
const paramName = entry.name.slice(2, -2);
|
|
156
|
-
const paramValue =
|
|
157
|
-
index < reqSegments.length
|
|
158
|
-
? safeDecode(reqSegments[index])
|
|
159
|
-
: undefined;
|
|
160
|
-
const newParams = {
|
|
161
|
-
...dParams,
|
|
162
|
-
[paramName]: paramValue,
|
|
163
|
-
};
|
|
164
|
-
const dynamicPath = path.join(currentPath, entry.name);
|
|
165
|
-
if (withExtension) {
|
|
166
|
-
for (const ext of possibleExtensions) {
|
|
167
|
-
const candidatePath = path.join(
|
|
168
|
-
dynamicPath,
|
|
169
|
-
`${fileName}${ext}`
|
|
170
|
-
);
|
|
171
|
-
if (existsSync(candidatePath)) {
|
|
172
|
-
isFound.value = true;
|
|
173
|
-
if (accumulative) {
|
|
174
|
-
const slots = getSlots(dynamicPath, reqSegments, query);
|
|
175
|
-
accumulate.push([candidatePath, newParams, slots]);
|
|
176
|
-
return accumulate;
|
|
177
|
-
}
|
|
178
|
-
return [candidatePath, newParams];
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
const candidatePath = path.join(dynamicPath, fileName);
|
|
183
|
-
if (existsSync(candidatePath)) {
|
|
184
|
-
isFound.value = true;
|
|
185
|
-
if (accumulative) {
|
|
186
|
-
const slots = getSlots(dynamicPath, reqSegments, query);
|
|
187
|
-
accumulate.push([candidatePath, newParams, slots]);
|
|
188
|
-
return accumulate;
|
|
189
|
-
}
|
|
190
|
-
return [candidatePath, newParams];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const newIsFound = { value: false };
|
|
194
|
-
const result = getFilePathAndDynamicParams(
|
|
195
|
-
reqSegments,
|
|
196
|
-
query,
|
|
197
|
-
dynamicPath,
|
|
198
|
-
fileName,
|
|
199
|
-
withExtension,
|
|
200
|
-
finalDestination,
|
|
201
|
-
lastFound,
|
|
202
|
-
index + 1,
|
|
203
|
-
dParams,
|
|
204
|
-
accumulative,
|
|
205
|
-
accumulate,
|
|
206
|
-
newIsFound
|
|
207
|
-
);
|
|
208
|
-
if (newIsFound.value) {
|
|
209
|
-
isFound.value = true;
|
|
210
|
-
return result;
|
|
211
|
-
}
|
|
212
|
-
if (accumulative) return accumulate;
|
|
213
|
-
return finalDestination
|
|
214
|
-
? []
|
|
215
|
-
: [foundInCurrentPath ?? lastFound, newParams];
|
|
216
|
-
} else if (entry.name.startsWith("(") && entry.name.endsWith(")")) {
|
|
217
|
-
const groupPath = path.join(currentPath, entry.name);
|
|
218
|
-
const newIsFound = { value: false };
|
|
219
|
-
const result = getFilePathAndDynamicParams(
|
|
220
|
-
reqSegments,
|
|
221
|
-
query,
|
|
222
|
-
groupPath,
|
|
223
|
-
fileName,
|
|
224
|
-
withExtension,
|
|
225
|
-
finalDestination,
|
|
226
|
-
lastFound,
|
|
227
|
-
index,
|
|
228
|
-
dParams,
|
|
229
|
-
accumulative,
|
|
230
|
-
accumulate,
|
|
231
|
-
newIsFound
|
|
232
|
-
);
|
|
233
|
-
if (newIsFound.value) {
|
|
234
|
-
isFound.value = true;
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
205
|
+
if (!isOptionalSingleDynamicDir(entry.name)) continue;
|
|
206
|
+
const paramName = entry.name.slice(2, -2);
|
|
207
|
+
const paramValue =
|
|
208
|
+
index < reqSegments.length
|
|
209
|
+
? safeDecode(reqSegments[index])
|
|
210
|
+
: undefined;
|
|
211
|
+
const newParams = {
|
|
212
|
+
...dParams,
|
|
213
|
+
[paramName]: paramValue,
|
|
214
|
+
};
|
|
215
|
+
if (!fallbackParams) fallbackParams = newParams;
|
|
216
|
+
const dynamicPath = path.join(currentPath, entry.name);
|
|
217
|
+
const directCandidate = findCandidateFile(
|
|
218
|
+
dynamicPath,
|
|
219
|
+
fileName,
|
|
220
|
+
withExtension,
|
|
221
|
+
possibleExtensions
|
|
222
|
+
);
|
|
223
|
+
if (directCandidate) {
|
|
224
|
+
isFound.value = true;
|
|
225
|
+
lineage.push({ dir: dynamicPath, dParams: newParams, index });
|
|
226
|
+
if (accumulative) {
|
|
227
|
+
const slots = getSlots(dynamicPath, reqSegments, query, newParams);
|
|
228
|
+
accumulate.push([directCandidate, newParams, slots]);
|
|
229
|
+
return accumulate;
|
|
237
230
|
}
|
|
231
|
+
return [directCandidate, newParams];
|
|
238
232
|
}
|
|
233
|
+
|
|
234
|
+
const branchAccumulate = [...accumulate];
|
|
235
|
+
const branchLineage = [...lineage];
|
|
236
|
+
const branchIsFound = { value: false };
|
|
237
|
+
const branchMaxDepth = { value: maxDepthRef.value };
|
|
238
|
+
const result = matchRouteTree(
|
|
239
|
+
reqSegments,
|
|
240
|
+
query,
|
|
241
|
+
dynamicPath,
|
|
242
|
+
fileName,
|
|
243
|
+
withExtension,
|
|
244
|
+
finalDestination,
|
|
245
|
+
foundInCurrentPath ?? lastFound,
|
|
246
|
+
index + 1,
|
|
247
|
+
dParams,
|
|
248
|
+
accumulative,
|
|
249
|
+
branchAccumulate,
|
|
250
|
+
branchIsFound,
|
|
251
|
+
possibleExtensions,
|
|
252
|
+
branchLineage,
|
|
253
|
+
branchMaxDepth
|
|
254
|
+
);
|
|
255
|
+
if (branchIsFound.value) {
|
|
256
|
+
isFound.value = true;
|
|
257
|
+
accumulate.splice(0, accumulate.length, ...branchAccumulate);
|
|
258
|
+
lineage.splice(0, lineage.length, ...branchLineage);
|
|
259
|
+
return accumulative ? accumulate : result;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 3. Optional catch-all segment: [[...param]]
|
|
264
|
+
for (const entry of entries) {
|
|
265
|
+
if (!isOptionalCatchAllDir(entry.name)) continue;
|
|
266
|
+
const paramName = entry.name.slice(5, -2);
|
|
267
|
+
const paramValue =
|
|
268
|
+
index < reqSegments.length
|
|
269
|
+
? reqSegments.slice(index).map(safeDecode)
|
|
270
|
+
: [];
|
|
271
|
+
const newParams = {
|
|
272
|
+
...dParams,
|
|
273
|
+
[paramName]: paramValue,
|
|
274
|
+
};
|
|
275
|
+
if (!fallbackParams) fallbackParams = newParams;
|
|
276
|
+
const dynamicPath = path.join(currentPath, entry.name);
|
|
277
|
+
const branchAccumulate = [...accumulate];
|
|
278
|
+
const branchLineage = [...lineage];
|
|
279
|
+
const branchIsFound = { value: false };
|
|
280
|
+
const branchMaxDepth = { value: maxDepthRef.value };
|
|
281
|
+
const result = matchRouteTree(
|
|
282
|
+
reqSegments,
|
|
283
|
+
query,
|
|
284
|
+
dynamicPath,
|
|
285
|
+
fileName,
|
|
286
|
+
withExtension,
|
|
287
|
+
finalDestination,
|
|
288
|
+
foundInCurrentPath ?? lastFound,
|
|
289
|
+
index,
|
|
290
|
+
newParams,
|
|
291
|
+
accumulative,
|
|
292
|
+
branchAccumulate,
|
|
293
|
+
branchIsFound,
|
|
294
|
+
possibleExtensions,
|
|
295
|
+
branchLineage,
|
|
296
|
+
branchMaxDepth
|
|
297
|
+
);
|
|
298
|
+
if (branchIsFound.value) {
|
|
299
|
+
isFound.value = true;
|
|
300
|
+
accumulate.splice(0, accumulate.length, ...branchAccumulate);
|
|
301
|
+
lineage.splice(0, lineage.length, ...branchLineage);
|
|
302
|
+
return accumulative ? accumulate : result;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!accumulative) {
|
|
307
|
+
return finalDestination
|
|
308
|
+
? []
|
|
309
|
+
: [foundInCurrentPath ?? lastFound, fallbackParams ?? dParams];
|
|
239
310
|
}
|
|
240
|
-
if (!accumulative) return finalDestination ? [] : [lastFound, dParams];
|
|
241
311
|
return accumulate;
|
|
242
312
|
}
|
|
243
313
|
}
|
|
244
|
-
|
|
314
|
+
|
|
315
|
+
const rawSeg = reqSegments[index];
|
|
316
|
+
const seg =
|
|
317
|
+
rawSeg === undefined || rawSeg === null ? rawSeg : String(rawSeg);
|
|
245
318
|
const isRouterSyntaxInSegment =
|
|
246
|
-
|
|
247
|
-
((
|
|
248
|
-
(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
319
|
+
seg &&
|
|
320
|
+
((seg.startsWith("(") && seg.endsWith(")")) ||
|
|
321
|
+
(seg.startsWith("[") && seg.endsWith("]")) ||
|
|
322
|
+
seg.startsWith("@") ||
|
|
323
|
+
seg.startsWith("_"));
|
|
324
|
+
|
|
325
|
+
const baseLastFound = finalDestination
|
|
326
|
+
? lastFound
|
|
327
|
+
: (foundInCurrentPath ?? lastFound);
|
|
328
|
+
const chains = collectGroupChains(currentPath);
|
|
329
|
+
let bestFallback = null;
|
|
330
|
+
|
|
331
|
+
function runCandidateBranch(
|
|
332
|
+
nextPath,
|
|
333
|
+
nextIndex,
|
|
334
|
+
nextParams,
|
|
335
|
+
groupDirs,
|
|
336
|
+
capDepthAt = null
|
|
337
|
+
) {
|
|
338
|
+
const chainAccumulate = [...accumulate];
|
|
339
|
+
let chainLastFound = baseLastFound;
|
|
340
|
+
const chainLineage = [...lineage];
|
|
341
|
+
|
|
342
|
+
for (const gDir of groupDirs) {
|
|
343
|
+
chainLineage.push({ dir: gDir, dParams, index });
|
|
344
|
+
if (!finalDestination) {
|
|
345
|
+
const gCand = findCandidateFile(
|
|
346
|
+
gDir,
|
|
347
|
+
fileName,
|
|
348
|
+
withExtension,
|
|
349
|
+
possibleExtensions
|
|
350
|
+
);
|
|
351
|
+
if (gCand) {
|
|
352
|
+
if (accumulative) {
|
|
353
|
+
const slots = getSlots(gDir, reqSegments, query, dParams);
|
|
354
|
+
chainAccumulate.push([gCand, dParams, slots]);
|
|
355
|
+
} else {
|
|
356
|
+
chainLastFound = gCand;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const branchIsFound = { value: false };
|
|
363
|
+
const branchMaxDepth = { value: maxDepthRef.value };
|
|
364
|
+
const result = matchRouteTree(
|
|
254
365
|
reqSegments,
|
|
255
366
|
query,
|
|
256
|
-
|
|
367
|
+
nextPath,
|
|
257
368
|
fileName,
|
|
258
369
|
withExtension,
|
|
259
370
|
finalDestination,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
371
|
+
chainLastFound,
|
|
372
|
+
nextIndex,
|
|
373
|
+
nextParams,
|
|
263
374
|
accumulative,
|
|
264
|
-
|
|
265
|
-
|
|
375
|
+
chainAccumulate,
|
|
376
|
+
branchIsFound,
|
|
377
|
+
possibleExtensions,
|
|
378
|
+
chainLineage,
|
|
379
|
+
branchMaxDepth
|
|
266
380
|
);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
|
|
382
|
+
if (branchIsFound.value) {
|
|
383
|
+
isFound.value = true;
|
|
384
|
+
accumulate.splice(0, accumulate.length, ...chainAccumulate);
|
|
385
|
+
lineage.splice(0, lineage.length, ...chainLineage);
|
|
386
|
+
maxDepthRef.value = branchMaxDepth.value;
|
|
387
|
+
return { matched: true, value: accumulative ? accumulate : result };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (!finalDestination) {
|
|
391
|
+
const effectiveDepth =
|
|
392
|
+
capDepthAt !== null
|
|
393
|
+
? Math.min(branchMaxDepth.value, capDepthAt)
|
|
394
|
+
: branchMaxDepth.value;
|
|
395
|
+
if (!bestFallback || effectiveDepth > bestFallback.depth) {
|
|
396
|
+
bestFallback = {
|
|
397
|
+
depth: effectiveDepth,
|
|
398
|
+
result,
|
|
399
|
+
branchAccumulate: chainAccumulate,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return { matched: false };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Tier 1: Static directory match (directly or inside route groups)
|
|
408
|
+
if (!isRouterSyntaxInSegment) {
|
|
409
|
+
for (const { targetDir, groupDirs, dirEntries } of chains) {
|
|
410
|
+
const hasStaticSubdir = dirEntries.some(
|
|
411
|
+
(e) =>
|
|
412
|
+
e.name === seg &&
|
|
413
|
+
!isGroupDir(e.name) &&
|
|
414
|
+
!isSingleDynamicDir(e.name) &&
|
|
415
|
+
!isOptionalSingleDynamicDir(e.name) &&
|
|
416
|
+
!isCatchAllDir(e.name) &&
|
|
417
|
+
!isOptionalCatchAllDir(e.name)
|
|
418
|
+
);
|
|
419
|
+
if (!hasStaticSubdir) continue;
|
|
420
|
+
const staticPath = path.join(targetDir, seg);
|
|
421
|
+
const attempt = runCandidateBranch(
|
|
422
|
+
staticPath,
|
|
423
|
+
index + 1,
|
|
424
|
+
dParams,
|
|
425
|
+
groupDirs
|
|
426
|
+
);
|
|
427
|
+
if (attempt.matched) return attempt.value;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Tier 2: Required single dynamic segment [param]
|
|
432
|
+
for (const { targetDir, groupDirs, dirEntries } of chains) {
|
|
433
|
+
for (const entry of dirEntries) {
|
|
434
|
+
if (!isSingleDynamicDir(entry.name)) continue;
|
|
435
|
+
const paramName = entry.name.slice(1, -1);
|
|
436
|
+
const paramValue = safeDecode(seg);
|
|
437
|
+
const newParams = {
|
|
438
|
+
...dParams,
|
|
439
|
+
[paramName]: paramValue,
|
|
440
|
+
};
|
|
441
|
+
const attempt = runCandidateBranch(
|
|
442
|
+
path.join(targetDir, entry.name),
|
|
443
|
+
index + 1,
|
|
444
|
+
newParams,
|
|
445
|
+
groupDirs
|
|
446
|
+
);
|
|
447
|
+
if (attempt.matched) return attempt.value;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Tier 3: Optional single dynamic segment [[param]]
|
|
452
|
+
for (const { targetDir, groupDirs, dirEntries } of chains) {
|
|
453
|
+
for (const entry of dirEntries) {
|
|
454
|
+
if (!isOptionalSingleDynamicDir(entry.name)) continue;
|
|
455
|
+
const paramName = entry.name.slice(2, -2);
|
|
456
|
+
const paramValue = safeDecode(seg);
|
|
457
|
+
const newParams = {
|
|
458
|
+
...dParams,
|
|
459
|
+
[paramName]: paramValue,
|
|
460
|
+
};
|
|
461
|
+
const attempt = runCandidateBranch(
|
|
462
|
+
path.join(targetDir, entry.name),
|
|
463
|
+
index + 1,
|
|
464
|
+
newParams,
|
|
465
|
+
groupDirs
|
|
466
|
+
);
|
|
467
|
+
if (attempt.matched) return attempt.value;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Tier 4: Required catch-all segment [...param]
|
|
472
|
+
for (const { targetDir, groupDirs, dirEntries } of chains) {
|
|
473
|
+
for (const entry of dirEntries) {
|
|
474
|
+
if (!isCatchAllDir(entry.name)) continue;
|
|
475
|
+
const paramName = entry.name.slice(4, -1);
|
|
476
|
+
const paramValue = reqSegments.slice(index).map(safeDecode);
|
|
477
|
+
const newParams = {
|
|
478
|
+
...dParams,
|
|
479
|
+
[paramName]: paramValue,
|
|
480
|
+
};
|
|
481
|
+
const attempt = runCandidateBranch(
|
|
482
|
+
path.join(targetDir, entry.name),
|
|
483
|
+
reqSegments.length,
|
|
484
|
+
newParams,
|
|
485
|
+
groupDirs,
|
|
486
|
+
index + 1
|
|
487
|
+
);
|
|
488
|
+
if (attempt.matched) return attempt.value;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Tier 5: Optional catch-all segment [[...param]]
|
|
493
|
+
for (const { targetDir, groupDirs, dirEntries } of chains) {
|
|
494
|
+
for (const entry of dirEntries) {
|
|
495
|
+
if (!isOptionalCatchAllDir(entry.name)) continue;
|
|
496
|
+
const paramName = entry.name.slice(5, -2);
|
|
497
|
+
const paramValue = reqSegments.slice(index).map(safeDecode);
|
|
498
|
+
const newParams = {
|
|
499
|
+
...dParams,
|
|
500
|
+
[paramName]: paramValue,
|
|
501
|
+
};
|
|
502
|
+
const attempt = runCandidateBranch(
|
|
503
|
+
path.join(targetDir, entry.name),
|
|
504
|
+
reqSegments.length,
|
|
505
|
+
newParams,
|
|
506
|
+
groupDirs,
|
|
507
|
+
index + 1
|
|
508
|
+
);
|
|
509
|
+
if (attempt.matched) return attempt.value;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (!finalDestination && bestFallback) {
|
|
514
|
+
maxDepthRef.value = bestFallback.depth;
|
|
515
|
+
if (accumulative) {
|
|
516
|
+
accumulate.splice(
|
|
517
|
+
0,
|
|
518
|
+
accumulate.length,
|
|
519
|
+
...bestFallback.branchAccumulate
|
|
520
|
+
);
|
|
521
|
+
return accumulate;
|
|
522
|
+
}
|
|
523
|
+
return bestFallback.result;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (!accumulative) {
|
|
527
|
+
return finalDestination ? [] : [baseLastFound, dParams];
|
|
528
|
+
}
|
|
529
|
+
return accumulate;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function getFilePathAndDynamicParams(
|
|
533
|
+
reqSegments,
|
|
534
|
+
query,
|
|
535
|
+
currentPath,
|
|
536
|
+
fileName = "page",
|
|
537
|
+
withExtension = true,
|
|
538
|
+
finalDestination = true,
|
|
539
|
+
lastFound = undefined,
|
|
540
|
+
index = 0,
|
|
541
|
+
dParams = {},
|
|
542
|
+
accumulative = false,
|
|
543
|
+
accumulate = [],
|
|
544
|
+
isFound = { value: false },
|
|
545
|
+
possibleExtensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"]
|
|
546
|
+
) {
|
|
547
|
+
const normCurrentPath = String(currentPath).replace(/\\/g, "/");
|
|
548
|
+
const isCompanionLookup =
|
|
549
|
+
index === 0 &&
|
|
550
|
+
!normCurrentPath.includes("/@") &&
|
|
551
|
+
(fileName === "layout" ||
|
|
552
|
+
fileName === "no_layout" ||
|
|
553
|
+
fileName === "error" ||
|
|
554
|
+
fileName === "not_found");
|
|
555
|
+
|
|
556
|
+
if (isCompanionLookup) {
|
|
557
|
+
const pageLineage = [];
|
|
558
|
+
const pageIsFound = { value: false };
|
|
559
|
+
matchRouteTree(
|
|
560
|
+
reqSegments,
|
|
561
|
+
query,
|
|
562
|
+
currentPath,
|
|
563
|
+
"page",
|
|
564
|
+
true,
|
|
565
|
+
true,
|
|
566
|
+
undefined,
|
|
567
|
+
0,
|
|
568
|
+
dParams,
|
|
569
|
+
false,
|
|
570
|
+
[],
|
|
571
|
+
pageIsFound,
|
|
572
|
+
[".tsx", ".ts", ".jsx", ".js", ".mjs"],
|
|
573
|
+
pageLineage,
|
|
574
|
+
{ value: 0 }
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
if (pageIsFound.value && pageLineage.length > 0) {
|
|
578
|
+
if (accumulative) {
|
|
579
|
+
for (const step of pageLineage) {
|
|
580
|
+
const candidatePath = findCandidateFile(
|
|
581
|
+
step.dir,
|
|
385
582
|
fileName,
|
|
386
583
|
withExtension,
|
|
387
|
-
|
|
388
|
-
finalDestination ? lastFound : foundInCurrentPath ?? lastFound,
|
|
389
|
-
index + 1,
|
|
390
|
-
newParams,
|
|
391
|
-
accumulative,
|
|
392
|
-
accumulate,
|
|
393
|
-
isFound
|
|
584
|
+
possibleExtensions
|
|
394
585
|
);
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
586
|
+
if (candidatePath) {
|
|
587
|
+
isFound.value = true;
|
|
588
|
+
const slots = getSlots(step.dir, reqSegments, query, step.dParams);
|
|
589
|
+
accumulate.push([candidatePath, step.dParams, slots]);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return accumulate;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (finalDestination) {
|
|
596
|
+
for (let i = pageLineage.length - 1; i >= 0; i--) {
|
|
597
|
+
if (pageLineage[i].index < reqSegments.length) break;
|
|
598
|
+
const candidatePath = findCandidateFile(
|
|
599
|
+
pageLineage[i].dir,
|
|
402
600
|
fileName,
|
|
403
601
|
withExtension,
|
|
404
|
-
|
|
405
|
-
lastFound,
|
|
406
|
-
index,
|
|
407
|
-
dParams,
|
|
408
|
-
accumulative,
|
|
409
|
-
accumulate,
|
|
410
|
-
newIsFound
|
|
602
|
+
possibleExtensions
|
|
411
603
|
);
|
|
412
|
-
if (
|
|
604
|
+
if (candidatePath) {
|
|
413
605
|
isFound.value = true;
|
|
414
|
-
return
|
|
606
|
+
return [candidatePath, pageLineage[i].dParams];
|
|
415
607
|
}
|
|
416
608
|
}
|
|
609
|
+
return [];
|
|
417
610
|
}
|
|
611
|
+
|
|
612
|
+
for (let i = pageLineage.length - 1; i >= 0; i--) {
|
|
613
|
+
const candidatePath = findCandidateFile(
|
|
614
|
+
pageLineage[i].dir,
|
|
615
|
+
fileName,
|
|
616
|
+
withExtension,
|
|
617
|
+
possibleExtensions
|
|
618
|
+
);
|
|
619
|
+
if (candidatePath) {
|
|
620
|
+
isFound.value = true;
|
|
621
|
+
return [candidatePath, pageLineage[i].dParams];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const leafParams = pageLineage[pageLineage.length - 1].dParams;
|
|
625
|
+
return [lastFound, leafParams];
|
|
418
626
|
}
|
|
419
|
-
if (!accumulative)
|
|
420
|
-
return finalDestination ? [] : [foundInCurrentPath ?? lastFound, dParams];
|
|
421
|
-
return accumulate;
|
|
422
627
|
}
|
|
628
|
+
|
|
629
|
+
return matchRouteTree(
|
|
630
|
+
reqSegments,
|
|
631
|
+
query,
|
|
632
|
+
currentPath,
|
|
633
|
+
fileName,
|
|
634
|
+
withExtension,
|
|
635
|
+
finalDestination,
|
|
636
|
+
lastFound,
|
|
637
|
+
index,
|
|
638
|
+
dParams,
|
|
639
|
+
accumulative,
|
|
640
|
+
accumulate,
|
|
641
|
+
isFound,
|
|
642
|
+
possibleExtensions,
|
|
643
|
+
[],
|
|
644
|
+
{ value: index }
|
|
645
|
+
);
|
|
423
646
|
}
|
|
424
647
|
|
|
425
648
|
export {
|