reroute-js 0.20.2 → 0.20.3
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.d.ts +1 -1
- package/cli/bin.js +238 -50
- package/cli/bin.js.map +14 -14
- package/cli/index.d.ts +1 -1
- package/cli/index.js +4 -4
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +2 -1
- package/cli/src/commands/build.d.ts.map +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/gen.d.ts.map +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/tailwind.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +150 -40
- package/core/index.js.map +12 -12
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts.map +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/discovery.d.ts.map +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/discovery.d.ts.map +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts.map +1 -1
- package/core/src/sitemap/generator.d.ts +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts.map +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/styles.d.ts.map +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +170 -41
- package/elysia/index.js.map +13 -13
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/plugin.d.ts.map +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
package/cli/bin.d.ts
CHANGED
package/cli/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
/**
|
|
4
|
-
* reroute-js v0.20.
|
|
4
|
+
* reroute-js v0.20.3
|
|
5
5
|
*
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -48,7 +48,7 @@ async function getVersionString() {
|
|
|
48
48
|
}
|
|
49
49
|
async function getVersion() {
|
|
50
50
|
if (true) {
|
|
51
|
-
return "0.20.
|
|
51
|
+
return "0.20.3";
|
|
52
52
|
}
|
|
53
53
|
const possiblePaths = [
|
|
54
54
|
path.join(import.meta.dir, "../../../../package.json"),
|
|
@@ -66,7 +66,7 @@ async function getVersion() {
|
|
|
66
66
|
}
|
|
67
67
|
async function getCommit() {
|
|
68
68
|
if (true) {
|
|
69
|
-
return "
|
|
69
|
+
return "71a926d";
|
|
70
70
|
}
|
|
71
71
|
return "dev";
|
|
72
72
|
}
|
|
@@ -944,9 +944,13 @@ async function computeLayoutData(pathname, clientDir, _cwd, isWatchMode, options
|
|
|
944
944
|
if (typeof layout?.path !== "string")
|
|
945
945
|
continue;
|
|
946
946
|
try {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
947
|
+
let ssrExport = layout?.ssr;
|
|
948
|
+
if (!ssrExport) {
|
|
949
|
+
const abs = join2(clientDir, "routes", String(layout.path));
|
|
950
|
+
const mod = await dynamicImport(abs, isWatchMode);
|
|
951
|
+
ssrExport = mod?.ssr;
|
|
952
|
+
}
|
|
953
|
+
const dataFn = ssrExport?.data;
|
|
950
954
|
if (typeof dataFn !== "function")
|
|
951
955
|
continue;
|
|
952
956
|
const pattern = String(layout.pattern || "/");
|
|
@@ -1042,9 +1046,13 @@ async function computeRouteData(pathname, clientDir, _cwd, isWatchMode, options2
|
|
|
1042
1046
|
if (!route || typeof route.path !== "string") {
|
|
1043
1047
|
return { data: ssrData, pendingTasks };
|
|
1044
1048
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1049
|
+
let ssrExport = route?.ssr;
|
|
1050
|
+
if (!ssrExport) {
|
|
1051
|
+
const abs = join2(clientDir, "routes", String(route.path));
|
|
1052
|
+
const mod = await dynamicImport(abs, isWatchMode);
|
|
1053
|
+
ssrExport = mod?.ssr;
|
|
1054
|
+
}
|
|
1055
|
+
const dataFn = ssrExport?.data;
|
|
1048
1056
|
if (typeof dataFn !== "function") {
|
|
1049
1057
|
return { data: ssrData, pendingTasks };
|
|
1050
1058
|
}
|
|
@@ -1176,6 +1184,24 @@ var init_routes = __esm(() => {
|
|
|
1176
1184
|
});
|
|
1177
1185
|
|
|
1178
1186
|
// packages/core/src/ssr/lib/compute/index.ts
|
|
1187
|
+
function matchPatternUtil(pattern, pathname) {
|
|
1188
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
1189
|
+
const pathnameParts = pathname.split("/").filter(Boolean);
|
|
1190
|
+
if (patternParts.length !== pathnameParts.length) {
|
|
1191
|
+
return null;
|
|
1192
|
+
}
|
|
1193
|
+
const params = {};
|
|
1194
|
+
for (let i = 0;i < patternParts.length; i++) {
|
|
1195
|
+
const patternPart = patternParts[i];
|
|
1196
|
+
const pathnamePart = pathnameParts[i];
|
|
1197
|
+
if (patternPart.startsWith(":")) {
|
|
1198
|
+
params[patternPart.slice(1)] = pathnamePart;
|
|
1199
|
+
} else if (patternPart !== pathnamePart) {
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
return params;
|
|
1204
|
+
}
|
|
1179
1205
|
async function computeSSRData(pathname, clientDir, cwd, isWatchMode, options2 = {}, searchParams) {
|
|
1180
1206
|
const ssrData = {};
|
|
1181
1207
|
let error;
|
|
@@ -1184,8 +1210,27 @@ async function computeSSRData(pathname, clientDir, cwd, isWatchMode, options2 =
|
|
|
1184
1210
|
const streaming = options2.streaming === true;
|
|
1185
1211
|
let routesModule;
|
|
1186
1212
|
try {
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1213
|
+
const bundledRoutes = globalThis.__REROUTE_ROUTES__;
|
|
1214
|
+
const bundledLayouts = globalThis.__REROUTE_LAYOUTS__;
|
|
1215
|
+
if (bundledRoutes && bundledLayouts) {
|
|
1216
|
+
routesModule = {
|
|
1217
|
+
routes: bundledRoutes,
|
|
1218
|
+
layouts: bundledLayouts,
|
|
1219
|
+
matchRoute: (pathname2) => {
|
|
1220
|
+
for (const route of bundledRoutes) {
|
|
1221
|
+
const pattern = String(route?.pattern || "");
|
|
1222
|
+
const match = matchPatternUtil(pattern, pathname2);
|
|
1223
|
+
if (match) {
|
|
1224
|
+
return { route, params: match };
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
} else {
|
|
1231
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
1232
|
+
routesModule = await dynamicImport(routesPath, isWatchMode);
|
|
1233
|
+
}
|
|
1189
1234
|
} catch {
|
|
1190
1235
|
return {
|
|
1191
1236
|
data: ssrData,
|
|
@@ -1373,6 +1418,24 @@ var init_seed = __esm(() => {
|
|
|
1373
1418
|
});
|
|
1374
1419
|
|
|
1375
1420
|
// packages/core/src/ssr/lib/data.ts
|
|
1421
|
+
function matchPattern(pattern, pathname) {
|
|
1422
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
1423
|
+
const pathnameParts = pathname.split("/").filter(Boolean);
|
|
1424
|
+
if (patternParts.length !== pathnameParts.length) {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1427
|
+
const params = {};
|
|
1428
|
+
for (let i = 0;i < patternParts.length; i++) {
|
|
1429
|
+
const patternPart = patternParts[i];
|
|
1430
|
+
const pathnamePart = pathnameParts[i];
|
|
1431
|
+
if (patternPart.startsWith(":")) {
|
|
1432
|
+
params[patternPart.slice(1)] = pathnamePart;
|
|
1433
|
+
} else if (patternPart !== pathnamePart) {
|
|
1434
|
+
return null;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return params;
|
|
1438
|
+
}
|
|
1376
1439
|
async function computeSSRDataForPath(params) {
|
|
1377
1440
|
const { pathname, clientDir, cwd, isWatchMode, searchParams } = params;
|
|
1378
1441
|
const allData = {};
|
|
@@ -1380,16 +1443,24 @@ async function computeSSRDataForPath(params) {
|
|
|
1380
1443
|
await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode);
|
|
1381
1444
|
} catch {}
|
|
1382
1445
|
try {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1446
|
+
let layouts = globalThis.__REROUTE_LAYOUTS__;
|
|
1447
|
+
if (!layouts) {
|
|
1448
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
1449
|
+
const m = await dynamicImport(routesPath, isWatchMode);
|
|
1450
|
+
layouts = m?.layouts;
|
|
1451
|
+
}
|
|
1452
|
+
const matchingLayouts = getMatchingLayouts(pathname, layouts);
|
|
1386
1453
|
for (const layout of matchingLayouts) {
|
|
1387
1454
|
if (typeof layout?.path !== "string")
|
|
1388
1455
|
continue;
|
|
1389
1456
|
try {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1457
|
+
let ssrExport = layout?.ssr;
|
|
1458
|
+
if (!ssrExport) {
|
|
1459
|
+
const abs = join2(clientDir, "routes", String(layout.path));
|
|
1460
|
+
const mod = await dynamicImport(abs, isWatchMode);
|
|
1461
|
+
ssrExport = mod?.ssr;
|
|
1462
|
+
}
|
|
1463
|
+
const dataFn = ssrExport?.data;
|
|
1393
1464
|
if (typeof dataFn !== "function")
|
|
1394
1465
|
continue;
|
|
1395
1466
|
const pattern = String(layout.pattern || "/");
|
|
@@ -1425,16 +1496,37 @@ async function computeSSRDataForPath(params) {
|
|
|
1425
1496
|
}
|
|
1426
1497
|
} catch {}
|
|
1427
1498
|
try {
|
|
1428
|
-
|
|
1429
|
-
|
|
1499
|
+
let routes = globalThis.__REROUTE_ROUTES__;
|
|
1500
|
+
let matchRouteFn;
|
|
1501
|
+
if (!routes) {
|
|
1502
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
1503
|
+
const m = await dynamicImport(routesPath, isWatchMode);
|
|
1504
|
+
routes = m?.routes;
|
|
1505
|
+
matchRouteFn = m?.matchRoute;
|
|
1506
|
+
} else {
|
|
1507
|
+
matchRouteFn = (pathname2) => {
|
|
1508
|
+
for (const route of routes || []) {
|
|
1509
|
+
const pattern = String(route?.pattern || "");
|
|
1510
|
+
const match2 = matchPattern(pattern, pathname2);
|
|
1511
|
+
if (match2) {
|
|
1512
|
+
return { route, params: match2 };
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return null;
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1430
1518
|
const pathnameOnly = pathname.split("?")[0];
|
|
1431
|
-
const match = typeof
|
|
1519
|
+
const match = typeof matchRouteFn === "function" ? matchRouteFn(pathnameOnly) : null;
|
|
1432
1520
|
const r = match?.route;
|
|
1433
1521
|
const paramsValue = match?.params || {};
|
|
1434
1522
|
if (r && typeof r.path === "string") {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1523
|
+
let ssrExport = r?.ssr;
|
|
1524
|
+
if (!ssrExport) {
|
|
1525
|
+
const abs = join2(clientDir, "routes", String(r.path));
|
|
1526
|
+
const mod = await dynamicImport(abs, isWatchMode);
|
|
1527
|
+
ssrExport = mod?.ssr;
|
|
1528
|
+
}
|
|
1529
|
+
const dataFn = ssrExport?.data;
|
|
1438
1530
|
if (typeof dataFn === "function") {
|
|
1439
1531
|
const rawResult = dataFn({
|
|
1440
1532
|
pathname,
|
|
@@ -2189,6 +2281,11 @@ var init_scripts = __esm(() => {
|
|
|
2189
2281
|
// packages/core/src/ssr/lib/styles.ts
|
|
2190
2282
|
async function inlineTailwindCSS(clientDir, minify = false) {
|
|
2191
2283
|
try {
|
|
2284
|
+
const bundledCss = globalThis.__REROUTE_THEME_CSS__;
|
|
2285
|
+
if (bundledCss) {
|
|
2286
|
+
const css2 = minify ? minifyCSS(bundledCss) : bundledCss;
|
|
2287
|
+
return `<style data-reroute="tailwind">${css2}</style>`;
|
|
2288
|
+
}
|
|
2192
2289
|
const candidates = [
|
|
2193
2290
|
join2(clientDir, "..", ".reroute", "theme.css"),
|
|
2194
2291
|
join2(clientDir, "..", "..", ".reroute", "theme.css"),
|
|
@@ -2743,10 +2840,13 @@ import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
|
2743
2840
|
async function discoverStaticRoutes(cwd, isWatchMode) {
|
|
2744
2841
|
const routes = [];
|
|
2745
2842
|
try {
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2843
|
+
let routesList = globalThis.__REROUTE_ROUTES__;
|
|
2844
|
+
if (!routesList) {
|
|
2845
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
2846
|
+
const url = pathToFileURL6(routesPath).href;
|
|
2847
|
+
const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
|
|
2848
|
+
routesList = mod?.routes;
|
|
2849
|
+
}
|
|
2750
2850
|
if (Array.isArray(routesList)) {
|
|
2751
2851
|
for (const route of routesList) {
|
|
2752
2852
|
const pattern = String(route?.pattern || "");
|
|
@@ -3219,10 +3319,13 @@ var init_og = __esm(() => {
|
|
|
3219
3319
|
async function discoverRoutesForRobots(cwd, isWatchMode) {
|
|
3220
3320
|
const routes = [];
|
|
3221
3321
|
try {
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3322
|
+
let routesArray = globalThis.__REROUTE_ROUTES__;
|
|
3323
|
+
if (!routesArray) {
|
|
3324
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
3325
|
+
const url = Bun.pathToFileURL(routesPath).href;
|
|
3326
|
+
const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
|
|
3327
|
+
routesArray = mod?.routes;
|
|
3328
|
+
}
|
|
3226
3329
|
if (Array.isArray(routesArray)) {
|
|
3227
3330
|
for (const route of routesArray) {
|
|
3228
3331
|
const pattern = String(route?.pattern || "");
|
|
@@ -3403,10 +3506,13 @@ async function discoverRoutes(cwd, isWatchMode) {
|
|
|
3403
3506
|
const staticRoutes = [];
|
|
3404
3507
|
const dynamicRoutes = [];
|
|
3405
3508
|
try {
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3509
|
+
let routes = globalThis.__REROUTE_ROUTES__;
|
|
3510
|
+
if (!routes) {
|
|
3511
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
3512
|
+
const url = Bun.pathToFileURL(routesPath).href;
|
|
3513
|
+
const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
|
|
3514
|
+
routes = mod?.routes;
|
|
3515
|
+
}
|
|
3410
3516
|
if (Array.isArray(routes)) {
|
|
3411
3517
|
for (const route of routes) {
|
|
3412
3518
|
const pattern = String(route?.pattern || "");
|
|
@@ -3880,10 +3986,13 @@ async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMod
|
|
|
3880
3986
|
async function discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig) {
|
|
3881
3987
|
const layoutFeeds = new Map;
|
|
3882
3988
|
try {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3989
|
+
let layouts2 = globalThis.__REROUTE_LAYOUTS__;
|
|
3990
|
+
if (!layouts2) {
|
|
3991
|
+
const routesPath = join2(cwd, ".reroute", "routes.ts");
|
|
3992
|
+
const url = pathToFileURL7(routesPath).href;
|
|
3993
|
+
const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
|
|
3994
|
+
layouts2 = mod?.layouts;
|
|
3995
|
+
}
|
|
3887
3996
|
if (Array.isArray(layouts2)) {
|
|
3888
3997
|
for (const layout of layouts2) {
|
|
3889
3998
|
const pattern = String(layout?.pattern || "/");
|
|
@@ -4231,8 +4340,9 @@ async function streamSSRContent(writer, encoder, ctx) {
|
|
|
4231
4340
|
try {
|
|
4232
4341
|
const combinedHead = deduplicateMetaTags([ctx.inlineStyleTag, ctx.head, ctx.extraHead].filter(Boolean).join(`
|
|
4233
4342
|
`));
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4343
|
+
const headWithLangAndContent = ctx.headWithLang.replace(/<html([^>]*)>/i, `<html$1 lang="${ctx.pageLang}">`).replace(/<\/head>/i, `${combinedHead ? `${combinedHead}
|
|
4344
|
+
` : ""}</head>`);
|
|
4345
|
+
const headContent = `${headWithLangAndContent}<body>`;
|
|
4236
4346
|
await writer.write(encoder.encode(headContent));
|
|
4237
4347
|
await writer.write(encoder.encode(ctx.rootStart));
|
|
4238
4348
|
const componentWithPathname = cloneElement2(ctx.rootComponent, {
|
|
@@ -8751,6 +8861,31 @@ import { watch } from "node:fs";
|
|
|
8751
8861
|
import { mkdir as mkdir2, readdir as readdir5, rm } from "node:fs/promises";
|
|
8752
8862
|
import { dirname as dirname5, join as join9 } from "node:path";
|
|
8753
8863
|
import { pathToFileURL as pathToFileURL8 } from "node:url";
|
|
8864
|
+
async function bundleThemeCssIntoArtifacts(cwd) {
|
|
8865
|
+
const themeCssPath = join9(cwd, ".reroute", "theme.css");
|
|
8866
|
+
const artifactsPath = join9(cwd, OUTPUT_ARTIFACTS);
|
|
8867
|
+
try {
|
|
8868
|
+
const cssContent = await Bun.file(themeCssPath).text();
|
|
8869
|
+
if (!cssContent)
|
|
8870
|
+
return;
|
|
8871
|
+
let artifactsContent = await Bun.file(artifactsPath).text();
|
|
8872
|
+
if (artifactsContent.includes("__REROUTE_THEME_CSS__")) {
|
|
8873
|
+
return;
|
|
8874
|
+
}
|
|
8875
|
+
const cssLine = `
|
|
8876
|
+
// Bundled theme.css for compiled binary support
|
|
8877
|
+
(globalThis as any).__REROUTE_THEME_CSS__ = ${JSON.stringify(cssContent)};
|
|
8878
|
+
`;
|
|
8879
|
+
const exportIndex = artifactsContent.lastIndexOf("export type RerouteBundle");
|
|
8880
|
+
if (exportIndex !== -1) {
|
|
8881
|
+
artifactsContent = artifactsContent.slice(0, exportIndex) + cssLine + `
|
|
8882
|
+
` + artifactsContent.slice(exportIndex);
|
|
8883
|
+
} else {
|
|
8884
|
+
artifactsContent += cssLine;
|
|
8885
|
+
}
|
|
8886
|
+
await Bun.write(artifactsPath, artifactsContent);
|
|
8887
|
+
} catch {}
|
|
8888
|
+
}
|
|
8754
8889
|
async function ensureOutputDir(cwd, options2 = {}) {
|
|
8755
8890
|
const { clean = true } = options2;
|
|
8756
8891
|
try {
|
|
@@ -8824,6 +8959,7 @@ export * from './artifacts';
|
|
|
8824
8959
|
// @ts-nocheck
|
|
8825
8960
|
|
|
8826
8961
|
import './artifacts';
|
|
8962
|
+
import './routes'; // Import routes (bundles all route components)
|
|
8827
8963
|
import '../src/index';
|
|
8828
8964
|
`;
|
|
8829
8965
|
await Bun.write(join9(cwd, OUTPUT_ROUTES), STUB_ROUTES);
|
|
@@ -8966,9 +9102,14 @@ function getImportPath(filePath, streamingMap) {
|
|
|
8966
9102
|
}
|
|
8967
9103
|
function generateTypeScript(tree, streamingMap) {
|
|
8968
9104
|
const helperImport = "import { createLazyRoute } from 'reroute-js/react';";
|
|
9105
|
+
const ssrHelper = "const _ssr = (m: any) => m.ssr;";
|
|
8969
9106
|
const eagerImports = [
|
|
8970
|
-
...tree.routes.map((r, i) => `import Route${i}
|
|
8971
|
-
|
|
9107
|
+
...tree.routes.map((r, i) => `import * as Route${i}Module from '${getImportPath(r.filePath, streamingMap)}';
|
|
9108
|
+
const Route${i}Eager = Route${i}Module.default;
|
|
9109
|
+
const Route${i}SSR = _ssr(Route${i}Module);`),
|
|
9110
|
+
...tree.layouts.map((l, i) => `import * as Layout${i}Module from '${getImportPath(l.filePath, streamingMap)}';
|
|
9111
|
+
const Layout${i}Eager = Layout${i}Module.default;
|
|
9112
|
+
const Layout${i}SSR = _ssr(Layout${i}Module);`),
|
|
8972
9113
|
...tree.notFoundRoutes.map((nf, i) => `import NotFound${i}Eager from '${getImportPath(nf.filePath, streamingMap)}';`)
|
|
8973
9114
|
].join(`
|
|
8974
9115
|
`);
|
|
@@ -8994,6 +9135,7 @@ function generateTypeScript(tree, streamingMap) {
|
|
|
8994
9135
|
component: Route${i},
|
|
8995
9136
|
params: ${JSON.stringify(r.params)},
|
|
8996
9137
|
isDynamic: ${r.isDynamic},
|
|
9138
|
+
ssr: Route${i}SSR,
|
|
8997
9139
|
} as const`;
|
|
8998
9140
|
}).join(`,
|
|
8999
9141
|
`);
|
|
@@ -9009,6 +9151,7 @@ function generateTypeScript(tree, streamingMap) {
|
|
|
9009
9151
|
pattern: "${l.pattern}",
|
|
9010
9152
|
path: "${l.path}",
|
|
9011
9153
|
component: Layout${i},
|
|
9154
|
+
ssr: Layout${i}SSR,
|
|
9012
9155
|
} as const`;
|
|
9013
9156
|
}).join(`,
|
|
9014
9157
|
`);
|
|
@@ -9026,6 +9169,8 @@ function generateTypeScript(tree, streamingMap) {
|
|
|
9026
9169
|
|
|
9027
9170
|
${helperImport}
|
|
9028
9171
|
|
|
9172
|
+
${ssrHelper}
|
|
9173
|
+
|
|
9029
9174
|
${eagerImports}
|
|
9030
9175
|
|
|
9031
9176
|
${lazyWrappers}
|
|
@@ -9090,6 +9235,10 @@ function matchPattern(pattern: string, pathname: string): Record<string, string>
|
|
|
9090
9235
|
|
|
9091
9236
|
return params;
|
|
9092
9237
|
}
|
|
9238
|
+
|
|
9239
|
+
// Set globals for compiled binary support (sitemap/RSS/robots discovery)
|
|
9240
|
+
(globalThis as any).__REROUTE_ROUTES__ = routes;
|
|
9241
|
+
(globalThis as any).__REROUTE_LAYOUTS__ = layouts;
|
|
9093
9242
|
`;
|
|
9094
9243
|
}
|
|
9095
9244
|
async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
|
|
@@ -9648,6 +9797,7 @@ async function generate(cwd, args = [], options2 = {}) {
|
|
|
9648
9797
|
"// @ts-nocheck",
|
|
9649
9798
|
"",
|
|
9650
9799
|
"import './artifacts'; // Import artifacts (sets globals for SSR)",
|
|
9800
|
+
"import './routes'; // Import routes (bundles all route components)",
|
|
9651
9801
|
"import '../src/index'; // Import user's server entry"
|
|
9652
9802
|
];
|
|
9653
9803
|
await Bun.write(join9(cwd, ".reroute/entry.ts"), entryLines.join(`
|
|
@@ -9677,6 +9827,7 @@ async function gen(args) {
|
|
|
9677
9827
|
if (!watchMode) {
|
|
9678
9828
|
await generate(cwd, args);
|
|
9679
9829
|
await buildTailwindIfConfigured(cwd, isProd);
|
|
9830
|
+
await bundleThemeCssIntoArtifacts(cwd);
|
|
9680
9831
|
checkMarkdownIfConfigured(cwd);
|
|
9681
9832
|
const genEndTime2 = performance.now();
|
|
9682
9833
|
const totalDuration2 = ((genEndTime2 - genStartTime) / 1000).toFixed(2);
|
|
@@ -9690,6 +9841,7 @@ async function gen(args) {
|
|
|
9690
9841
|
await generate(cwd, args);
|
|
9691
9842
|
try {
|
|
9692
9843
|
await buildTailwindIfConfigured(cwd, isProd);
|
|
9844
|
+
await bundleThemeCssIntoArtifacts(cwd);
|
|
9693
9845
|
checkMarkdownIfConfigured(cwd);
|
|
9694
9846
|
} catch {}
|
|
9695
9847
|
const genEndTime = performance.now();
|
|
@@ -10490,8 +10642,14 @@ __export(exports_build, {
|
|
|
10490
10642
|
default: () => build
|
|
10491
10643
|
});
|
|
10492
10644
|
import { spawn as spawn4 } from "node:child_process";
|
|
10493
|
-
import {
|
|
10494
|
-
|
|
10645
|
+
import {
|
|
10646
|
+
cpSync,
|
|
10647
|
+
existsSync as existsSync8,
|
|
10648
|
+
mkdirSync,
|
|
10649
|
+
readdirSync,
|
|
10650
|
+
readFileSync as readFileSync5
|
|
10651
|
+
} from "node:fs";
|
|
10652
|
+
import { dirname as dirname6, join as join12 } from "node:path";
|
|
10495
10653
|
function getRerouteCommand3() {
|
|
10496
10654
|
const binPath = join12(import.meta.dir, "..", "..", "bin.ts");
|
|
10497
10655
|
const isBunDev = existsSync8(binPath);
|
|
@@ -10603,7 +10761,7 @@ async function build(args) {
|
|
|
10603
10761
|
return arg !== "--outfile" && arg !== "-o" && arg !== "--minify" && arg !== "--no-minify" && arg !== "--prod";
|
|
10604
10762
|
});
|
|
10605
10763
|
buildArgs.push(...filteredArgs, "--outfile", outputPath);
|
|
10606
|
-
await new Promise((
|
|
10764
|
+
await new Promise((_resolve, reject) => {
|
|
10607
10765
|
const buildProcess = spawn4("bun", buildArgs, {
|
|
10608
10766
|
stdio: "inherit"
|
|
10609
10767
|
});
|
|
@@ -10613,13 +10771,42 @@ async function build(args) {
|
|
|
10613
10771
|
} else {
|
|
10614
10772
|
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Build complete: ${outputPath}
|
|
10615
10773
|
`));
|
|
10616
|
-
|
|
10774
|
+
process.exit(0);
|
|
10617
10775
|
}
|
|
10618
10776
|
});
|
|
10619
10777
|
buildProcess.on("error", (error) => {
|
|
10620
10778
|
reject(error);
|
|
10621
10779
|
});
|
|
10622
10780
|
});
|
|
10781
|
+
const cwd = process.cwd();
|
|
10782
|
+
const config2 = await loadConfig(cwd);
|
|
10783
|
+
const assetsPath = config2.options?.assets || "src/client";
|
|
10784
|
+
const sourceAssetsDir = join12(cwd, assetsPath, "assets");
|
|
10785
|
+
const distDir = dirname6(outputPath);
|
|
10786
|
+
const destAssetsDir = join12(distDir, "assets");
|
|
10787
|
+
if (existsSync8(sourceAssetsDir)) {
|
|
10788
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copying assets...
|
|
10789
|
+
`));
|
|
10790
|
+
if (!existsSync8(distDir)) {
|
|
10791
|
+
mkdirSync(distDir, { recursive: true });
|
|
10792
|
+
}
|
|
10793
|
+
cpSync(sourceAssetsDir, destAssetsDir, { recursive: true });
|
|
10794
|
+
const countFiles = (dir) => {
|
|
10795
|
+
let count = 0;
|
|
10796
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
10797
|
+
for (const entry of entries) {
|
|
10798
|
+
if (entry.isDirectory()) {
|
|
10799
|
+
count += countFiles(join12(dir, entry.name));
|
|
10800
|
+
} else {
|
|
10801
|
+
count++;
|
|
10802
|
+
}
|
|
10803
|
+
}
|
|
10804
|
+
return count;
|
|
10805
|
+
};
|
|
10806
|
+
const fileCount = countFiles(destAssetsDir);
|
|
10807
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copied ${fileCount} assets to ${destAssetsDir}
|
|
10808
|
+
`));
|
|
10809
|
+
}
|
|
10623
10810
|
} catch (error) {
|
|
10624
10811
|
process.stderr.write(`${colorizeLogPrefixAnsi("[reroute/build] Error: ") + String(error)}
|
|
10625
10812
|
`);
|
|
@@ -10627,6 +10814,7 @@ async function build(args) {
|
|
|
10627
10814
|
}
|
|
10628
10815
|
}
|
|
10629
10816
|
var init_build = __esm(() => {
|
|
10817
|
+
init_core();
|
|
10630
10818
|
init_log();
|
|
10631
10819
|
});
|
|
10632
10820
|
|
|
@@ -13201,7 +13389,7 @@ async function getVersionString2() {
|
|
|
13201
13389
|
}
|
|
13202
13390
|
async function getVersion2() {
|
|
13203
13391
|
if (true) {
|
|
13204
|
-
return "0.20.
|
|
13392
|
+
return "0.20.3";
|
|
13205
13393
|
}
|
|
13206
13394
|
const possiblePaths = [
|
|
13207
13395
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -13218,10 +13406,10 @@ async function getVersion2() {
|
|
|
13218
13406
|
}
|
|
13219
13407
|
async function getCommit2() {
|
|
13220
13408
|
if (true) {
|
|
13221
|
-
return "
|
|
13409
|
+
return "71a926d";
|
|
13222
13410
|
}
|
|
13223
13411
|
return "dev";
|
|
13224
13412
|
}
|
|
13225
13413
|
main();
|
|
13226
13414
|
|
|
13227
|
-
//# debugId=
|
|
13415
|
+
//# debugId=92865B18E2048CEB64756E2164756E21
|