reroute-js 0.45.11 → 0.45.12-beta.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/cli/bin.js CHANGED
@@ -15,25 +15,43 @@ var __getProtoOf = Object.getPrototypeOf;
15
15
  var __defProp = Object.defineProperty;
16
16
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ function __accessProp(key) {
19
+ return this[key];
20
+ }
21
+ var __toESMCache_node;
22
+ var __toESMCache_esm;
18
23
  var __toESM = (mod, isNodeMode, target) => {
24
+ var canCache = mod != null && typeof mod === "object";
25
+ if (canCache) {
26
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
27
+ var cached = cache.get(mod);
28
+ if (cached)
29
+ return cached;
30
+ }
19
31
  target = mod != null ? __create(__getProtoOf(mod)) : {};
20
32
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
21
33
  for (let key of __getOwnPropNames(mod))
22
34
  if (!__hasOwnProp.call(to, key))
23
35
  __defProp(to, key, {
24
- get: () => mod[key],
36
+ get: __accessProp.bind(mod, key),
25
37
  enumerable: true
26
38
  });
39
+ if (canCache)
40
+ cache.set(mod, to);
27
41
  return to;
28
42
  };
29
43
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
44
+ var __returnValue = (v) => v;
45
+ function __exportSetter(name, newValue) {
46
+ this[name] = __returnValue.bind(null, newValue);
47
+ }
30
48
  var __export = (target, all) => {
31
49
  for (var name in all)
32
50
  __defProp(target, name, {
33
51
  get: all[name],
34
52
  enumerable: true,
35
53
  configurable: true,
36
- set: (newValue) => all[name] = () => newValue
54
+ set: __exportSetter.bind(all, name)
37
55
  });
38
56
  };
39
57
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -66,7 +84,7 @@ async function getVersion() {
66
84
  }
67
85
  async function getCommit() {
68
86
  if (true) {
69
- return "c2463d3";
87
+ return "c64466b";
70
88
  }
71
89
  return "dev";
72
90
  }
@@ -1112,6 +1130,103 @@ function compressStreamIfAccepted(stream, contentType, _acceptEncoding) {
1112
1130
  }
1113
1131
  var init_compression = () => {};
1114
1132
 
1133
+ // packages/core/src/ssr/lib/route-match.ts
1134
+ function getPatternParts(pattern) {
1135
+ return pattern.split("/").filter(Boolean);
1136
+ }
1137
+ function isDynamicPatternPart(patternPart) {
1138
+ return patternPart.startsWith(":");
1139
+ }
1140
+ function isCatchAllPatternPart(patternPart) {
1141
+ return patternPart.startsWith(":...");
1142
+ }
1143
+ function isCatchAllParamName(paramName) {
1144
+ return paramName.startsWith("...");
1145
+ }
1146
+ function getPatternPartSpecificity(patternPart) {
1147
+ if (isCatchAllPatternPart(patternPart)) {
1148
+ return 2;
1149
+ }
1150
+ if (isDynamicPatternPart(patternPart)) {
1151
+ return 1;
1152
+ }
1153
+ return 0;
1154
+ }
1155
+ function compareRouteSpecificity(a, b) {
1156
+ const aPatternParts = getPatternParts(a.pattern);
1157
+ const bPatternParts = getPatternParts(b.pattern);
1158
+ const aDepth = aPatternParts.length;
1159
+ const bDepth = bPatternParts.length;
1160
+ if (aDepth !== bDepth) {
1161
+ return bDepth - aDepth;
1162
+ }
1163
+ for (let i = 0;i < aPatternParts.length; i++) {
1164
+ const aSpecificity = getPatternPartSpecificity(aPatternParts[i]);
1165
+ const bSpecificity = getPatternPartSpecificity(bPatternParts[i]);
1166
+ if (aSpecificity !== bSpecificity) {
1167
+ return aSpecificity - bSpecificity;
1168
+ }
1169
+ if (aSpecificity === 0 && aPatternParts[i] !== bPatternParts[i]) {
1170
+ return aPatternParts[i].localeCompare(bPatternParts[i]);
1171
+ }
1172
+ }
1173
+ return a.pattern.localeCompare(b.pattern);
1174
+ }
1175
+ function matchCatchAllParam(paramName, patternIndex, patternLength, pathnameParts, pathnameIndex, params) {
1176
+ if (patternIndex !== patternLength - 1 || pathnameIndex >= pathnameParts.length) {
1177
+ return false;
1178
+ }
1179
+ params[paramName.slice(3)] = pathnameParts.slice(pathnameIndex).join("/");
1180
+ return true;
1181
+ }
1182
+ function matchDynamicParam(paramName, pathnameParts, pathnameIndex, params) {
1183
+ const pathnamePart = pathnameParts[pathnameIndex];
1184
+ if (pathnamePart === undefined) {
1185
+ return null;
1186
+ }
1187
+ params[paramName] = pathnamePart;
1188
+ return pathnameIndex + 1;
1189
+ }
1190
+ function matchPatternPart(patternPart, patternIndex, patternLength, pathnameParts, pathnameIndex, params) {
1191
+ if (isDynamicPatternPart(patternPart)) {
1192
+ const paramName = patternPart.slice(1);
1193
+ if (isCatchAllParamName(paramName)) {
1194
+ return matchCatchAllParam(paramName, patternIndex, patternLength, pathnameParts, pathnameIndex, params) ? "catch-all" : null;
1195
+ }
1196
+ return matchDynamicParam(paramName, pathnameParts, pathnameIndex, params);
1197
+ }
1198
+ if (patternPart !== pathnameParts[pathnameIndex]) {
1199
+ return null;
1200
+ }
1201
+ return pathnameIndex + 1;
1202
+ }
1203
+ function matchRoutePattern(pattern, pathname) {
1204
+ const patternParts = getPatternParts(pattern);
1205
+ const pathnameParts = pathname.split("/").filter(Boolean);
1206
+ const params = {};
1207
+ let pathnameIndex = 0;
1208
+ for (let i = 0;i < patternParts.length; i++) {
1209
+ const nextPathnameIndex = matchPatternPart(patternParts[i], i, patternParts.length, pathnameParts, pathnameIndex, params);
1210
+ if (nextPathnameIndex === null) {
1211
+ return null;
1212
+ }
1213
+ if (nextPathnameIndex === "catch-all") {
1214
+ return params;
1215
+ }
1216
+ pathnameIndex = nextPathnameIndex;
1217
+ }
1218
+ return pathnameIndex === pathnameParts.length ? params : null;
1219
+ }
1220
+ function matchRoutes(routes, pathname) {
1221
+ for (const route of routes) {
1222
+ const params = matchRoutePattern(route.pattern, pathname);
1223
+ if (params) {
1224
+ return { route, params };
1225
+ }
1226
+ }
1227
+ return null;
1228
+ }
1229
+
1115
1230
  // packages/core/src/ssr/lib/compute/content.ts
1116
1231
  function checkStatusCache(statusCacheKey, maxAgeMs) {
1117
1232
  if (maxAgeMs <= 0)
@@ -1578,40 +1693,13 @@ var init_routes = __esm(() => {
1578
1693
  });
1579
1694
 
1580
1695
  // packages/core/src/ssr/lib/compute/index.ts
1581
- function matchPatternUtil(pattern, pathname) {
1582
- const patternParts = pattern.split("/").filter(Boolean);
1583
- const pathnameParts = pathname.split("/").filter(Boolean);
1584
- if (patternParts.length !== pathnameParts.length) {
1585
- return null;
1586
- }
1587
- const params = {};
1588
- for (let i = 0;i < patternParts.length; i++) {
1589
- const patternPart = patternParts[i];
1590
- const pathnamePart = pathnameParts[i];
1591
- if (patternPart.startsWith(":")) {
1592
- params[patternPart.slice(1)] = pathnamePart;
1593
- } else if (patternPart !== pathnamePart) {
1594
- return null;
1595
- }
1596
- }
1597
- return params;
1598
- }
1599
1696
  function createBundledRoutesModule(bundledRoutes, bundledLayouts) {
1600
1697
  const bundledNotFoundRoutes = globalThis.__REROUTE_NOT_FOUND_ROUTES__;
1601
1698
  return {
1602
1699
  routes: bundledRoutes,
1603
1700
  layouts: bundledLayouts,
1604
1701
  notFoundRoutes: bundledNotFoundRoutes,
1605
- matchRoute: (pathname) => {
1606
- for (const route of bundledRoutes) {
1607
- const pattern = String(route?.pattern || "");
1608
- const match = matchPatternUtil(pattern, pathname);
1609
- if (match) {
1610
- return { route, params: match };
1611
- }
1612
- }
1613
- return null;
1614
- }
1702
+ matchRoute: (pathname) => matchRoutes(bundledRoutes, pathname)
1615
1703
  };
1616
1704
  }
1617
1705
  async function loadRoutesModule(cwd, isWatchMode) {
@@ -1844,24 +1932,6 @@ var init_seed = __esm(() => {
1844
1932
  });
1845
1933
 
1846
1934
  // packages/core/src/ssr/lib/data.ts
1847
- function matchPattern(pattern, pathname) {
1848
- const patternParts = pattern.split("/").filter(Boolean);
1849
- const pathnameParts = pathname.split("/").filter(Boolean);
1850
- if (patternParts.length !== pathnameParts.length) {
1851
- return null;
1852
- }
1853
- const params = {};
1854
- for (let i = 0;i < patternParts.length; i++) {
1855
- const patternPart = patternParts[i];
1856
- const pathnamePart = pathnameParts[i];
1857
- if (patternPart.startsWith(":")) {
1858
- params[patternPart.slice(1)] = pathnamePart;
1859
- } else if (patternPart !== pathnamePart) {
1860
- return null;
1861
- }
1862
- }
1863
- return params;
1864
- }
1865
1935
  function loadContentData(pathname, searchParams) {
1866
1936
  try {
1867
1937
  const parts = pathname.split("/").filter(Boolean);
@@ -1896,16 +1966,7 @@ async function loadRouteDataInternal(pathname, clientDir, cwd, isWatchMode, sear
1896
1966
  routes = m?.routes;
1897
1967
  matchRouteFn = m?.matchRoute;
1898
1968
  } else {
1899
- matchRouteFn = (pathname2) => {
1900
- for (const route of routes || []) {
1901
- const pattern = String(route?.pattern || "");
1902
- const match2 = matchPattern(pattern, pathname2);
1903
- if (match2) {
1904
- return { route, params: match2 };
1905
- }
1906
- }
1907
- return null;
1908
- };
1969
+ matchRouteFn = (pathname2) => matchRoutes(routes || [], pathname2);
1909
1970
  }
1910
1971
  const pathnameOnly = pathname.split("?")[0];
1911
1972
  const match = typeof matchRouteFn === "function" ? matchRouteFn(pathnameOnly) : null;
@@ -2246,18 +2307,53 @@ function replaceAppRoot(html, appHtml, appId) {
2246
2307
  var init_html = () => {};
2247
2308
 
2248
2309
  // packages/core/src/og/discovery.ts
2310
+ import { readdir as readdir4 } from "node:fs/promises";
2249
2311
  import { pathToFileURL as pathToFileURL4 } from "node:url";
2312
+ function isCatchAllRouteDirectory(name) {
2313
+ return CATCH_ALL_ROUTE_DIRECTORY.test(name);
2314
+ }
2315
+ async function listDynamicRouteDirectories(baseDir) {
2316
+ try {
2317
+ const entries = await readdir4(baseDir, { withFileTypes: true });
2318
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => DYNAMIC_ROUTE_DIRECTORY.test(name)).sort((a, b) => {
2319
+ const aIsCatchAll = isCatchAllRouteDirectory(a);
2320
+ const bIsCatchAll = isCatchAllRouteDirectory(b);
2321
+ if (aIsCatchAll !== bIsCatchAll) {
2322
+ return Number(aIsCatchAll) - Number(bIsCatchAll);
2323
+ }
2324
+ return a.localeCompare(b);
2325
+ });
2326
+ } catch {
2327
+ return [];
2328
+ }
2329
+ }
2330
+ async function collectOGCandidatePaths(currentDir, parts, depth, pathsToTry, allowPartialFallback) {
2331
+ if (depth === parts.length) {
2332
+ pathsToTry.push(join2(currentDir, "[og].tsx"));
2333
+ return;
2334
+ }
2335
+ const literalDir = join2(currentDir, parts[depth]);
2336
+ try {
2337
+ await readdir4(literalDir);
2338
+ await collectOGCandidatePaths(literalDir, parts, depth + 1, pathsToTry, true);
2339
+ } catch {}
2340
+ const dynamicDirs = await listDynamicRouteDirectories(currentDir);
2341
+ for (const dynamicDir of dynamicDirs) {
2342
+ if (isCatchAllRouteDirectory(dynamicDir)) {
2343
+ pathsToTry.push(join2(currentDir, dynamicDir, "[og].tsx"));
2344
+ continue;
2345
+ }
2346
+ await collectOGCandidatePaths(join2(currentDir, dynamicDir), parts, depth + 1, pathsToTry, false);
2347
+ }
2348
+ if (allowPartialFallback) {
2349
+ pathsToTry.push(join2(currentDir, "[og].tsx"));
2350
+ }
2351
+ }
2250
2352
  async function findOGImageForPath(pathname, clientDir) {
2251
2353
  const parts = pathname.split("/").filter(Boolean).filter((p) => !p.startsWith("__reroute"));
2252
2354
  const routesDir = join2(clientDir, "routes");
2253
2355
  const pathsToTry = [];
2254
- if (parts.length > 0) {
2255
- for (let i = parts.length;i > 0; i--) {
2256
- const dirPath = join2(routesDir, ...parts.slice(0, i), "[og].tsx");
2257
- pathsToTry.push(dirPath);
2258
- }
2259
- }
2260
- pathsToTry.push(join2(routesDir, "[og].tsx"));
2356
+ await collectOGCandidatePaths(routesDir, parts, 0, pathsToTry, true);
2261
2357
  const uniquePaths = [...new Set(pathsToTry)];
2262
2358
  for (const path2 of uniquePaths) {
2263
2359
  try {
@@ -2281,28 +2377,28 @@ async function loadOGImageComponent(ogPath, isWatchMode) {
2281
2377
  function extractParamsFromPath(pathname, ogPath, clientDir) {
2282
2378
  const params = {};
2283
2379
  const ogDir = ogPath.replace(/\/\[og\]\.tsx$/, "");
2284
- const pagesDir = join2(clientDir, "pages");
2285
- const relativePath = ogDir.replace(pagesDir, "").split("/").filter(Boolean);
2380
+ const routesDir = join2(clientDir, "routes");
2381
+ const relativePath = ogDir.replace(routesDir, "").split("/").filter(Boolean);
2286
2382
  const pathnameParts = pathname.split("/").filter(Boolean);
2287
2383
  for (let i = 0;i < relativePath.length && i < pathnameParts.length; i++) {
2288
2384
  const part = relativePath[i];
2289
- const match = part.match(/^\[([^\]]+)\]$/);
2290
- if (match) {
2291
- const paramName = match[1];
2292
- params[paramName] = pathnameParts[i];
2385
+ const catchAllMatch = part.match(/^\[\.\.\.([^\]]+)\]$/);
2386
+ if (catchAllMatch) {
2387
+ params[catchAllMatch[1]] = pathnameParts.slice(i).join("/");
2388
+ break;
2293
2389
  }
2294
- }
2295
- if (pathnameParts.length > relativePath.length && relativePath.length > 0) {
2296
- const lastRelativePart = relativePath[relativePath.length - 1];
2297
- const match = lastRelativePart.match(/^\[([^\]]+)\]$/);
2298
- if (match) {
2299
- const paramName = match[1];
2300
- params[paramName] = pathnameParts[relativePath.length - 1];
2390
+ const dynamicMatch = part.match(/^\[([^\]]+)\]$/);
2391
+ if (dynamicMatch) {
2392
+ params[dynamicMatch[1]] = pathnameParts[i];
2301
2393
  }
2302
2394
  }
2303
2395
  return params;
2304
2396
  }
2305
- var init_discovery2 = () => {};
2397
+ var CATCH_ALL_ROUTE_DIRECTORY, DYNAMIC_ROUTE_DIRECTORY;
2398
+ var init_discovery2 = __esm(() => {
2399
+ CATCH_ALL_ROUTE_DIRECTORY = /^\[\.\.\.([^\]]+)\]$/;
2400
+ DYNAMIC_ROUTE_DIRECTORY = /^\[(?:\.\.\.)?[^\]]+\]$/;
2401
+ });
2306
2402
 
2307
2403
  // packages/core/src/og/meta.ts
2308
2404
  async function generateOGImageMetaTags(pathname, clientDir, ogConfig) {
@@ -2749,7 +2845,7 @@ var init_metadata2 = __esm(() => {
2749
2845
  });
2750
2846
 
2751
2847
  // packages/core/src/ssr/lib/preload.ts
2752
- import { readdir as readdir4, stat as stat4 } from "node:fs/promises";
2848
+ import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
2753
2849
  async function preloadContentModule(pathname, clientDir, cwd, isWatchMode) {
2754
2850
  let extraHead = "";
2755
2851
  let hydrationScript = "";
@@ -2825,7 +2921,7 @@ async function findContentModulePath(collection, name, clientDir, cwd, isWatchMo
2825
2921
  } catch {}
2826
2922
  try {
2827
2923
  const chunkDir = join2(cwd, ".reroute", "chunks", collection);
2828
- const files = await readdir4(chunkDir);
2924
+ const files = await readdir5(chunkDir);
2829
2925
  const candidates = files.filter((n) => n.startsWith(`${name}.`) && n.endsWith(".js"));
2830
2926
  if (candidates.length) {
2831
2927
  const latest = await findLatestCandidate(chunkDir, candidates);
@@ -5922,6 +6018,8 @@ __export(exports_core, {
5922
6018
  preloadContentModule: () => preloadContentModule,
5923
6019
  performSSRSetup: () => performSSRSetup,
5924
6020
  mergeLayoutData: () => mergeLayoutData,
6021
+ matchRoutes: () => matchRoutes,
6022
+ matchRoutePattern: () => matchRoutePattern,
5925
6023
  loadRoutesModule: () => loadRoutesModule,
5926
6024
  loadOGImageComponent: () => loadOGImageComponent,
5927
6025
  loadIndexHtml: () => loadIndexHtml,
@@ -5991,6 +6089,7 @@ __export(exports_core, {
5991
6089
  computeLayoutData: () => computeLayoutData,
5992
6090
  computeContentData: () => computeContentData,
5993
6091
  compressStreamIfAccepted: () => compressStreamIfAccepted,
6092
+ compareRouteSpecificity: () => compareRouteSpecificity,
5994
6093
  cleanupPathScopedSSRData: () => cleanupPathScopedSSRData,
5995
6094
  buildHeadFromMeta: () => buildHeadFromMeta,
5996
6095
  blockSearchCrawlers: () => blockSearchCrawlers,
@@ -6848,7 +6947,7 @@ __export(exports_gen, {
6848
6947
  default: () => gen
6849
6948
  });
6850
6949
  import { watch } from "node:fs";
6851
- import { mkdir as mkdir2, readdir as readdir5, rm } from "node:fs/promises";
6950
+ import { mkdir as mkdir2, readdir as readdir6, rm } from "node:fs/promises";
6852
6951
  import { dirname as dirname5, join as join9 } from "node:path";
6853
6952
  import { pathToFileURL as pathToFileURL8 } from "node:url";
6854
6953
  async function bundleThemeCssIntoArtifacts(cwd) {
@@ -6883,7 +6982,7 @@ async function ensureOutputDir(cwd, options = {}) {
6883
6982
  if (clean) {
6884
6983
  let needsCleanup = false;
6885
6984
  try {
6886
- const entries = await readdir5(outputPath);
6985
+ const entries = await readdir6(outputPath);
6887
6986
  needsCleanup = entries.length > 0;
6888
6987
  } catch {}
6889
6988
  if (needsCleanup) {
@@ -6976,7 +7075,7 @@ function shouldSkipFile(relativePath, entryName) {
6976
7075
  }
6977
7076
  async function scanDirectory(dir, base = "") {
6978
7077
  const files = [];
6979
- const entries = await readdir5(dir, { withFileTypes: true });
7078
+ const entries = await readdir6(dir, { withFileTypes: true });
6980
7079
  for (const entry of entries) {
6981
7080
  const fullPath = join9(dir, entry.name);
6982
7081
  const relativePath = join9(base, entry.name);
@@ -6995,7 +7094,7 @@ async function scanDirectory(dir, base = "") {
6995
7094
  }
6996
7095
  async function scan404Files(dir, base = "") {
6997
7096
  const files = [];
6998
- const entries = await readdir5(dir, { withFileTypes: true });
7097
+ const entries = await readdir6(dir, { withFileTypes: true });
6999
7098
  for (const entry of entries) {
7000
7099
  const fullPath = join9(dir, entry.name);
7001
7100
  const relativePath = join9(base, entry.name);
@@ -7011,7 +7110,7 @@ async function scan404Files(dir, base = "") {
7011
7110
  }
7012
7111
  async function scanOgFiles(dir, base = "") {
7013
7112
  const files = [];
7014
- const entries = await readdir5(dir, { withFileTypes: true });
7113
+ const entries = await readdir6(dir, { withFileTypes: true });
7015
7114
  for (const entry of entries) {
7016
7115
  const fullPath = join9(dir, entry.name);
7017
7116
  const relativePath = join9(base, entry.name);
@@ -7068,17 +7167,7 @@ function fileToRoute(filePath) {
7068
7167
  };
7069
7168
  }
7070
7169
  function sortRoutes(routes) {
7071
- return routes.sort((a, b) => {
7072
- const aDepth = a.pattern.split("/").length;
7073
- const bDepth = b.pattern.split("/").length;
7074
- if (aDepth !== bDepth)
7075
- return bDepth - aDepth;
7076
- const aDynamicCount = a.params.length;
7077
- const bDynamicCount = b.params.length;
7078
- if (aDynamicCount !== bDynamicCount)
7079
- return aDynamicCount - bDynamicCount;
7080
- return a.pattern.localeCompare(b.pattern);
7081
- });
7170
+ return routes.sort((a, b) => compareRouteSpecificity(a, b));
7082
7171
  }
7083
7172
  function generateRouteTree(files) {
7084
7173
  const routes = [];
@@ -7237,26 +7326,38 @@ export function matchRoute(pathname: string): { route: Route; params: Record<str
7237
7326
  function matchPattern(route: Route, pathname: string): Record<string, string> | null {
7238
7327
  const patternParts = route.pattern.split('/').filter(Boolean);
7239
7328
  const pathnameParts = pathname.split('/').filter(Boolean);
7240
-
7241
- if (patternParts.length !== pathnameParts.length) {
7242
- return null;
7243
- }
7244
-
7245
7329
  const params: Record<string, string> = {};
7330
+ let pathnameIndex = 0;
7246
7331
 
7247
7332
  for (let i = 0; i < patternParts.length; i++) {
7248
7333
  const patternPart = patternParts[i];
7249
- const pathnamePart = pathnameParts[i];
7250
7334
 
7251
7335
  if (patternPart.startsWith(':')) {
7252
7336
  const paramName = patternPart.slice(1);
7337
+ if (paramName.startsWith('...')) {
7338
+ if (i !== patternParts.length - 1 || pathnameIndex >= pathnameParts.length) {
7339
+ return null;
7340
+ }
7341
+
7342
+ params[paramName.slice(3)] = pathnameParts.slice(pathnameIndex).join('/');
7343
+ return params;
7344
+ }
7345
+
7346
+ const pathnamePart = pathnameParts[pathnameIndex];
7347
+ if (pathnamePart === undefined) {
7348
+ return null;
7349
+ }
7350
+
7253
7351
  params[paramName] = pathnamePart;
7254
- } else if (patternPart !== pathnamePart) {
7352
+ pathnameIndex += 1;
7353
+ } else if (patternPart !== pathnameParts[pathnameIndex]) {
7255
7354
  return null;
7355
+ } else {
7356
+ pathnameIndex += 1;
7256
7357
  }
7257
7358
  }
7258
7359
 
7259
- return params;
7360
+ return pathnameIndex === pathnameParts.length ? params : null;
7260
7361
  }
7261
7362
 
7262
7363
  // Set globals for compiled binary support (sitemap/RSS/robots discovery)
@@ -7313,7 +7414,7 @@ async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
7313
7414
  }
7314
7415
  async function listContentFiles2(collectionDir) {
7315
7416
  try {
7316
- const entries = await readdir5(collectionDir, { withFileTypes: true });
7417
+ const entries = await readdir6(collectionDir, { withFileTypes: true });
7317
7418
  return entries.filter((e) => e.isFile() && /\.(tsx|ts|md|mdx)$/.test(e.name) && !e.name.startsWith("_")).map((e) => e.name);
7318
7419
  } catch {
7319
7420
  return [];
@@ -7460,7 +7561,7 @@ async function buildSingleContentChunk(cwd, collection, file, contentDir, args)
7460
7561
  async function buildContentChunks(cwd, args = []) {
7461
7562
  const routesRoot = join9(cwd, ROUTES_DIR);
7462
7563
  console.log(`[reroute/content] scan ${routesRoot}`);
7463
- const collections2 = await readdir5(routesRoot, { withFileTypes: true });
7564
+ const collections2 = await readdir6(routesRoot, { withFileTypes: true });
7464
7565
  const results = [];
7465
7566
  for (const c of collections2) {
7466
7567
  if (!c.isDirectory())
@@ -7557,7 +7658,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
7557
7658
  maxHeadingLevel = 6
7558
7659
  } = searchConfig;
7559
7660
  const routesRoot = join9(cwd, ROUTES_DIR);
7560
- const collections2 = await readdir5(routesRoot, { withFileTypes: true });
7661
+ const collections2 = await readdir6(routesRoot, { withFileTypes: true });
7561
7662
  const searchIndex = [];
7562
7663
  for (const c of collections2) {
7563
7664
  if (!c.isDirectory())
@@ -7568,7 +7669,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
7568
7669
  }
7569
7670
  const contentDir = join9(routesRoot, collection, "content");
7570
7671
  try {
7571
- const files = await readdir5(contentDir);
7672
+ const files = await readdir6(contentDir);
7572
7673
  for (const file of files) {
7573
7674
  if (!/\.(md|mdx)$/.test(file))
7574
7675
  continue;
@@ -7633,7 +7734,7 @@ async function preprocessMarkdownFiles(cwd, config2) {
7633
7734
  async function scanMarkdown(dir, base = "") {
7634
7735
  const files = [];
7635
7736
  try {
7636
- const entries = await readdir5(dir, { withFileTypes: true });
7737
+ const entries = await readdir6(dir, { withFileTypes: true });
7637
7738
  for (const entry of entries) {
7638
7739
  const fullPath = join9(dir, entry.name);
7639
7740
  const relativePath = join9(base, entry.name);
@@ -7793,7 +7894,7 @@ async function buildEntrypointBundle(cwd, args = []) {
7793
7894
  }
7794
7895
  const newFiles = new Set(outputs.map((o) => o.fileName));
7795
7896
  try {
7796
- const existingFiles = await readdir5(bundlesDir);
7897
+ const existingFiles = await readdir6(bundlesDir);
7797
7898
  for (const file of existingFiles) {
7798
7899
  if (/^(index|chunk|asset)\.[a-z0-9]+\.(js|css|js\.map|css\.map)(\.gz|\.br)?$/i.test(file) && !newFiles.has(file.replace(/\.(gz|br)$/, ""))) {
7799
7900
  await rm(join9(bundlesDir, file), { force: true });
@@ -7917,7 +8018,7 @@ async function generate(cwd, args = [], options = {}) {
7917
8018
  const contentRoutes = [];
7918
8019
  const collectionsDir = join9(cwd, ".reroute", "collections");
7919
8020
  try {
7920
- const collectionFiles = await readdir5(collectionsDir);
8021
+ const collectionFiles = await readdir6(collectionsDir);
7921
8022
  for (const file of collectionFiles) {
7922
8023
  if (file.endsWith(".js")) {
7923
8024
  const collectionPath = join9(collectionsDir, file);
@@ -8933,7 +9034,7 @@ var require_alias = __commonJS((exports) => {
8933
9034
 
8934
9035
  // node_modules/.bun/blessed@0.1.81/node_modules/blessed/lib/tput.js
8935
9036
  var require_tput = __commonJS((exports, module) => {
8936
- var __dirname = "/home/runner/work/reroute/reroute/node_modules/.bun/blessed@0.1.81/node_modules/blessed/lib";
9037
+ var __dirname = "/Users/stewan/dev/reroute/node_modules/.bun/blessed@0.1.81/node_modules/blessed/lib";
8937
9038
  var assert = __require("assert");
8938
9039
  var path3 = __require("path");
8939
9040
  var fs = __require("fs");
@@ -103673,7 +103774,7 @@ __export(exports_analyze, {
103673
103774
  default: () => analyze
103674
103775
  });
103675
103776
  import { existsSync as existsSync11, statSync } from "node:fs";
103676
- import { readdir as readdir6, readFile, stat as stat5, writeFile } from "node:fs/promises";
103777
+ import { readdir as readdir7, readFile, stat as stat5, writeFile } from "node:fs/promises";
103677
103778
  import { basename as basename3, join as join15, relative as relative3 } from "node:path";
103678
103779
  import Table from "cli-table3";
103679
103780
  async function findChunkBundles(cwd) {
@@ -103681,12 +103782,12 @@ async function findChunkBundles(cwd) {
103681
103782
  const chunksDir = join15(cwd, ".reroute", "chunks");
103682
103783
  if (!existsSync11(chunksDir))
103683
103784
  return bundles;
103684
- const collections2 = await readdir6(chunksDir, { withFileTypes: true });
103785
+ const collections2 = await readdir7(chunksDir, { withFileTypes: true });
103685
103786
  for (const collection of collections2) {
103686
103787
  if (!collection.isDirectory())
103687
103788
  continue;
103688
103789
  const collectionDir = join15(chunksDir, collection.name);
103689
- const files = await readdir6(collectionDir);
103790
+ const files = await readdir7(collectionDir);
103690
103791
  for (const file of files) {
103691
103792
  if (!file.endsWith(".js"))
103692
103793
  continue;
@@ -103711,7 +103812,7 @@ async function findDistBundles(cwd) {
103711
103812
  const distDir = join15(cwd, "dist");
103712
103813
  if (!existsSync11(distDir))
103713
103814
  return bundles;
103714
- const files = await readdir6(distDir);
103815
+ const files = await readdir7(distDir);
103715
103816
  for (const file of files) {
103716
103817
  const filePath = join15(distDir, file);
103717
103818
  const stats = statSync(filePath);
@@ -104170,7 +104271,7 @@ async function generateHTMLReport(stats, depTree, mainInfo, browserDepTree, brow
104170
104271
  try {
104171
104272
  const distDir = join15(process.cwd(), "dist");
104172
104273
  if (existsSync11(distDir)) {
104173
- const files = await readdir6(distDir);
104274
+ const files = await readdir7(distDir);
104174
104275
  for (const file of files) {
104175
104276
  const filePath = join15(distDir, file);
104176
104277
  const stats2 = statSync(filePath);
@@ -105656,7 +105757,7 @@ async function printConsoleReport(stats, depTree, mainInfo, browserDepTree, brow
105656
105757
  try {
105657
105758
  const distDir = join15(process.cwd(), "dist");
105658
105759
  if (existsSync11(distDir)) {
105659
- const files = await readdir6(distDir);
105760
+ const files = await readdir7(distDir);
105660
105761
  for (const file of files) {
105661
105762
  const filePath = join15(distDir, file);
105662
105763
  const stats2 = statSync(filePath);
@@ -105900,7 +106001,7 @@ __export(exports_og, {
105900
106001
  default: () => og2
105901
106002
  });
105902
106003
  import { spawn as spawn5 } from "node:child_process";
105903
- import { readdir as readdir7 } from "node:fs/promises";
106004
+ import { readdir as readdir8 } from "node:fs/promises";
105904
106005
  import { join as join16 } from "node:path";
105905
106006
  function getPortFromConfig(baseUrl) {
105906
106007
  if (!baseUrl)
@@ -105978,7 +106079,7 @@ Error output:`, errorOutput);
105978
106079
  }
105979
106080
  async function scanForOgTemplates(dir, base, routes) {
105980
106081
  try {
105981
- const entries = await readdir7(dir, { withFileTypes: true });
106082
+ const entries = await readdir8(dir, { withFileTypes: true });
105982
106083
  for (const entry of entries) {
105983
106084
  const fullPath = join16(dir, entry.name);
105984
106085
  const relativePath = join16(base, entry.name);
@@ -105998,13 +106099,13 @@ function findFirstContentFile(contentFiles) {
105998
106099
  }
105999
106100
  async function addContentRoutes(routesPath, routes) {
106000
106101
  try {
106001
- const entries = await readdir7(routesPath, { withFileTypes: true });
106102
+ const entries = await readdir8(routesPath, { withFileTypes: true });
106002
106103
  for (const entry of entries) {
106003
106104
  if (!entry.isDirectory())
106004
106105
  continue;
106005
106106
  const contentDir = join16(routesPath, entry.name, "content");
106006
106107
  try {
106007
- const contentFiles = await readdir7(contentDir);
106108
+ const contentFiles = await readdir8(contentDir);
106008
106109
  if (contentFiles.length === 0)
106009
106110
  continue;
106010
106111
  const firstFile = findFirstContentFile(contentFiles);
@@ -106299,10 +106400,10 @@ async function getVersion2() {
106299
106400
  }
106300
106401
  async function getCommit2() {
106301
106402
  if (true) {
106302
- return "c2463d3";
106403
+ return "c64466b";
106303
106404
  }
106304
106405
  return "dev";
106305
106406
  }
106306
106407
  main();
106307
106408
 
106308
- //# debugId=AD9BC92E9CCB37B264756E2164756E21
106409
+ //# debugId=7E1CB9A746872E8064756E2164756E21