reroute-js 0.30.3 → 0.31.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.d.ts +1 -1
- package/cli/bin.js +180 -47
- package/cli/bin.js.map +7 -7
- 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 +1 -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/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.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/terminal-ui.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/og.d.ts.map +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 +4 -3
- package/core/index.js.map +4 -4
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +12 -1
- package/core/src/config.d.ts.map +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.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 +8 -1
- package/core/src/og/render.d.ts.map +1 -1
- package/core/src/og/types.d.ts +3 -1
- package/core/src/og/types.d.ts.map +1 -1
- package/core/src/robots/discovery.d.ts +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/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/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/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts +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/serialize.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/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/elysia/index.d.ts +1 -1
- package/elysia/index.js +148 -48
- package/elysia/index.js.map +5 -5
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.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/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/og.d.ts.map +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/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +2 -2
- package/telemetry/react.js.map +1 -1
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +2 -2
- package/telemetry/server.js.map +4 -4
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/index.d.ts +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/sourcemap.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.
|
|
4
|
+
* reroute-js v0.31.1
|
|
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.
|
|
51
|
+
return "0.31.1";
|
|
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 "0cea34b";
|
|
70
70
|
}
|
|
71
71
|
return "dev";
|
|
72
72
|
}
|
|
@@ -3748,7 +3748,8 @@ async function renderOGImageToPNG(Component, props, options = {}) {
|
|
|
3748
3748
|
const element = createElement(Component, props);
|
|
3749
3749
|
const imageResponse = new ImageResponse(element, {
|
|
3750
3750
|
width,
|
|
3751
|
-
height
|
|
3751
|
+
height,
|
|
3752
|
+
fonts: options.fonts
|
|
3752
3753
|
});
|
|
3753
3754
|
const arrayBuffer = await imageResponse.arrayBuffer();
|
|
3754
3755
|
return Buffer.from(arrayBuffer);
|
|
@@ -6211,6 +6212,24 @@ async function scan404Files(dir, base = "") {
|
|
|
6211
6212
|
}
|
|
6212
6213
|
return files;
|
|
6213
6214
|
}
|
|
6215
|
+
async function scanOgFiles(dir, base = "") {
|
|
6216
|
+
const files = [];
|
|
6217
|
+
const entries = await readdir5(dir, { withFileTypes: true });
|
|
6218
|
+
for (const entry of entries) {
|
|
6219
|
+
const fullPath = join9(dir, entry.name);
|
|
6220
|
+
const relativePath = join9(base, entry.name);
|
|
6221
|
+
if (entry.isDirectory()) {
|
|
6222
|
+
if (entry.name === "content")
|
|
6223
|
+
continue;
|
|
6224
|
+
const nested = await scanOgFiles(fullPath, relativePath);
|
|
6225
|
+
files.push(...nested);
|
|
6226
|
+
} else if (entry.isFile()) {
|
|
6227
|
+
if (/^\[og]\.(tsx|ts)$/.test(entry.name))
|
|
6228
|
+
files.push(relativePath);
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6231
|
+
return files;
|
|
6232
|
+
}
|
|
6214
6233
|
function fileToRoute(filePath) {
|
|
6215
6234
|
const isLayout = filePath.endsWith("[layout].tsx") || filePath.endsWith("[layout].ts") || filePath.endsWith("[layout].md") || filePath.endsWith("[layout].mdx");
|
|
6216
6235
|
let routePath = filePath.replace(/\.(tsx|ts|md|mdx)$/, "");
|
|
@@ -6894,6 +6913,19 @@ async function buildEntrypointBundle(cwd, args = []) {
|
|
|
6894
6913
|
conditions: ["browser", "import", "module", "default"],
|
|
6895
6914
|
external: [
|
|
6896
6915
|
"sharp",
|
|
6916
|
+
"@opentelemetry/api",
|
|
6917
|
+
"@opentelemetry/api-logs",
|
|
6918
|
+
"@opentelemetry/exporter-logs-otlp-proto",
|
|
6919
|
+
"@opentelemetry/exporter-metrics-otlp-proto",
|
|
6920
|
+
"@opentelemetry/exporter-trace-otlp-http",
|
|
6921
|
+
"@opentelemetry/exporter-trace-otlp-proto",
|
|
6922
|
+
"@opentelemetry/instrumentation",
|
|
6923
|
+
"@opentelemetry/resources",
|
|
6924
|
+
"@opentelemetry/sdk-logs",
|
|
6925
|
+
"@opentelemetry/sdk-metrics",
|
|
6926
|
+
"@opentelemetry/sdk-trace-base",
|
|
6927
|
+
"@opentelemetry/sdk-trace-node",
|
|
6928
|
+
"@opentelemetry/semantic-conventions",
|
|
6897
6929
|
"perf_hooks",
|
|
6898
6930
|
"node:perf_hooks",
|
|
6899
6931
|
"child_process",
|
|
@@ -7153,6 +7185,19 @@ async function generate(cwd, args = [], options = {}) {
|
|
|
7153
7185
|
const appPath = config2.options.app.startsWith(".") ? `../${config2.options.app}` : config2.options.app;
|
|
7154
7186
|
indexLines.push(`import AppComponent from '${appPath}';`);
|
|
7155
7187
|
}
|
|
7188
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7189
|
+
const ogTemplatePath = config2.ogImage.defaultTemplate.startsWith(".") ? `../${config2.ogImage.defaultTemplate}` : config2.ogImage.defaultTemplate;
|
|
7190
|
+
indexLines.push(`import OGTemplate from '${ogTemplatePath}';`);
|
|
7191
|
+
}
|
|
7192
|
+
const ogFiles = await scanOgFiles(join9(cwd, ROUTES_DIR));
|
|
7193
|
+
const ogImports = [];
|
|
7194
|
+
for (let i = 0;i < ogFiles.length; i++) {
|
|
7195
|
+
const ogFile = ogFiles[i];
|
|
7196
|
+
const importName = `OGRoute${i}`;
|
|
7197
|
+
const importPath = `../src/client/routes/${ogFile.replace(/\.(tsx|ts)$/, "")}`;
|
|
7198
|
+
indexLines.push(`import ${importName} from '${importPath}';`);
|
|
7199
|
+
ogImports.push({ path: ogFile, name: importName });
|
|
7200
|
+
}
|
|
7156
7201
|
indexLines.push("");
|
|
7157
7202
|
indexLines.push("export const bundle = {");
|
|
7158
7203
|
indexLines.push(" layouts,");
|
|
@@ -7165,12 +7210,31 @@ async function generate(cwd, args = [], options = {}) {
|
|
|
7165
7210
|
if (config2.options?.app) {
|
|
7166
7211
|
indexLines.push(" AppComponent,");
|
|
7167
7212
|
}
|
|
7213
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7214
|
+
indexLines.push(" OGTemplate,");
|
|
7215
|
+
}
|
|
7168
7216
|
indexLines.push("} as const;");
|
|
7169
7217
|
if (config2.options?.app) {
|
|
7170
7218
|
indexLines.push("");
|
|
7171
7219
|
indexLines.push("// Set global for compiled binary SSR support");
|
|
7172
7220
|
indexLines.push("(globalThis as any).__REROUTE_APP_COMPONENT__ = AppComponent;");
|
|
7173
7221
|
}
|
|
7222
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7223
|
+
indexLines.push("");
|
|
7224
|
+
indexLines.push("// Set global for compiled binary OG template support");
|
|
7225
|
+
indexLines.push("(globalThis as any).__REROUTE_OG_TEMPLATE__ = OGTemplate;");
|
|
7226
|
+
}
|
|
7227
|
+
if (ogImports.length > 0) {
|
|
7228
|
+
indexLines.push("");
|
|
7229
|
+
indexLines.push("// Route-specific OG templates for compiled binary support");
|
|
7230
|
+
indexLines.push("(globalThis as any).__REROUTE_OG_ROUTES__ = {");
|
|
7231
|
+
for (const { path: path3, name } of ogImports) {
|
|
7232
|
+
const routePath = path3.replace(/\/?\[og]\.(tsx|ts)$/, "").replace(/\\/g, "/");
|
|
7233
|
+
const normalizedPath = routePath ? `/${routePath}` : "/";
|
|
7234
|
+
indexLines.push(` '${normalizedPath}': ${name},`);
|
|
7235
|
+
}
|
|
7236
|
+
indexLines.push("};");
|
|
7237
|
+
}
|
|
7174
7238
|
const templatePath = join9(cwd, "src", "client", "index.html");
|
|
7175
7239
|
try {
|
|
7176
7240
|
const templateContent = await Bun.file(templatePath).text();
|
|
@@ -102560,6 +102624,17 @@ function cleanDistFolder(cwd) {
|
|
|
102560
102624
|
rmSync(distDir, { recursive: true });
|
|
102561
102625
|
}
|
|
102562
102626
|
}
|
|
102627
|
+
async function cleanRerouteFolder(cwd) {
|
|
102628
|
+
const rerouteDir = join13(cwd, ".reroute");
|
|
102629
|
+
if (existsSync9(rerouteDir)) {
|
|
102630
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Cleaning .reroute folder...
|
|
102631
|
+
`));
|
|
102632
|
+
rmSync(rerouteDir, { recursive: true, force: true });
|
|
102633
|
+
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
102634
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] ✓ .reroute folder cleaned
|
|
102635
|
+
`));
|
|
102636
|
+
}
|
|
102637
|
+
}
|
|
102563
102638
|
function createOutputHandler(genBuffer) {
|
|
102564
102639
|
return (data) => {
|
|
102565
102640
|
const text = genBuffer.current + data.toString();
|
|
@@ -102616,7 +102691,12 @@ async function copyAssets(cwd) {
|
|
|
102616
102691
|
}
|
|
102617
102692
|
}
|
|
102618
102693
|
async function buildBundle(cwd, buildArgs) {
|
|
102619
|
-
const external = [
|
|
102694
|
+
const external = [
|
|
102695
|
+
"sharp",
|
|
102696
|
+
"@opentelemetry/*",
|
|
102697
|
+
"@vercel/og",
|
|
102698
|
+
...buildArgs.externalArgs
|
|
102699
|
+
];
|
|
102620
102700
|
const buildResult = await Bun.build({
|
|
102621
102701
|
entrypoints: [join13(cwd, ".reroute/entry.ts")],
|
|
102622
102702
|
target: "bun",
|
|
@@ -102701,6 +102781,7 @@ async function build(args) {
|
|
|
102701
102781
|
try {
|
|
102702
102782
|
const buildStartTime = performance.now();
|
|
102703
102783
|
cleanDistFolder(cwd);
|
|
102784
|
+
await cleanRerouteFolder(cwd);
|
|
102704
102785
|
const rerouteCmd = getRerouteCommand3();
|
|
102705
102786
|
const useShell = rerouteCmd.includes(" ");
|
|
102706
102787
|
await runGenCommand(rerouteCmd, useShell, buildArgs.noCompression);
|
|
@@ -104986,24 +105067,46 @@ __export(exports_og, {
|
|
|
104986
105067
|
import { spawn as spawn5 } from "node:child_process";
|
|
104987
105068
|
import { readdir as readdir7 } from "node:fs/promises";
|
|
104988
105069
|
import { join as join16 } from "node:path";
|
|
104989
|
-
|
|
104990
|
-
|
|
104991
|
-
|
|
104992
|
-
|
|
104993
|
-
|
|
104994
|
-
|
|
104995
|
-
|
|
104996
|
-
|
|
104997
|
-
throw new Error("Failed to allocate port");
|
|
105070
|
+
function getPortFromConfig(baseUrl) {
|
|
105071
|
+
if (!baseUrl)
|
|
105072
|
+
return 3000;
|
|
105073
|
+
try {
|
|
105074
|
+
const url = new URL(baseUrl);
|
|
105075
|
+
return url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80;
|
|
105076
|
+
} catch {
|
|
105077
|
+
return 3000;
|
|
104998
105078
|
}
|
|
104999
|
-
return port;
|
|
105000
105079
|
}
|
|
105001
|
-
async function
|
|
105002
|
-
|
|
105003
|
-
|
|
105004
|
-
|
|
105080
|
+
async function killProcessOnPort(port) {
|
|
105081
|
+
try {
|
|
105082
|
+
const proc = spawn5("bunx", ["kill-port", String(port)], {
|
|
105083
|
+
stdio: "ignore"
|
|
105084
|
+
});
|
|
105085
|
+
await new Promise((resolve2) => {
|
|
105086
|
+
proc.on("close", () => resolve2());
|
|
105087
|
+
});
|
|
105088
|
+
} catch {}
|
|
105089
|
+
}
|
|
105090
|
+
async function isServerRunning(port) {
|
|
105091
|
+
try {
|
|
105092
|
+
const response = await fetch(`http://localhost:${port}`, {
|
|
105093
|
+
signal: AbortSignal.timeout(1000)
|
|
105094
|
+
});
|
|
105095
|
+
return response.ok || response.status < 500;
|
|
105096
|
+
} catch {
|
|
105097
|
+
return false;
|
|
105098
|
+
}
|
|
105099
|
+
}
|
|
105100
|
+
async function ensureServer(cwd, port) {
|
|
105101
|
+
const alreadyRunning = await isServerRunning(port);
|
|
105102
|
+
if (alreadyRunning) {
|
|
105103
|
+
console.log(`✅ Dev server already running at http://localhost:${port}
|
|
105104
|
+
`);
|
|
105105
|
+
return { port, process: null, wasAlreadyRunning: true };
|
|
105106
|
+
}
|
|
105107
|
+
console.log(`\uD83D\uDE80 Starting dev server on port ${port}...`);
|
|
105108
|
+
const proc = spawn5("reroute", ["dev"], {
|
|
105005
105109
|
cwd,
|
|
105006
|
-
env: { ...process.env, PORT: String(port) },
|
|
105007
105110
|
stdio: ["ignore", "pipe", "pipe"],
|
|
105008
105111
|
detached: false
|
|
105009
105112
|
});
|
|
@@ -105012,7 +105115,7 @@ async function startServer(cwd) {
|
|
|
105012
105115
|
proc.stderr?.on("data", (data) => {
|
|
105013
105116
|
errorOutput += data.toString();
|
|
105014
105117
|
});
|
|
105015
|
-
for (let i = 0;i <
|
|
105118
|
+
for (let i = 0;i < 60; i++) {
|
|
105016
105119
|
await Bun.sleep(500);
|
|
105017
105120
|
try {
|
|
105018
105121
|
const response = await fetch(`http://localhost:${port}`, {
|
|
@@ -105034,9 +105137,9 @@ async function startServer(cwd) {
|
|
|
105034
105137
|
console.error(`
|
|
105035
105138
|
Error output:`, errorOutput);
|
|
105036
105139
|
}
|
|
105037
|
-
throw new Error("Server failed to start within
|
|
105140
|
+
throw new Error("Server failed to start within 30 seconds");
|
|
105038
105141
|
}
|
|
105039
|
-
return { port, process: proc };
|
|
105142
|
+
return { port, process: proc, wasAlreadyRunning: false };
|
|
105040
105143
|
}
|
|
105041
105144
|
async function scanForOgTemplates(dir, base, routes) {
|
|
105042
105145
|
try {
|
|
@@ -105079,11 +105182,24 @@ async function addContentRoutes(routesPath, routes) {
|
|
|
105079
105182
|
} catch {}
|
|
105080
105183
|
}
|
|
105081
105184
|
async function findRoutesWithOG(cwd) {
|
|
105082
|
-
const routesPath = join16(cwd, ROUTES_DIR2);
|
|
105083
105185
|
const routes = [];
|
|
105084
|
-
|
|
105085
|
-
|
|
105086
|
-
|
|
105186
|
+
try {
|
|
105187
|
+
const manifestPath = join16(cwd, ".reroute", "manifest.json");
|
|
105188
|
+
const manifestFile = Bun.file(manifestPath);
|
|
105189
|
+
const manifest = await manifestFile.json();
|
|
105190
|
+
if (manifest.staticRoutes && Array.isArray(manifest.staticRoutes)) {
|
|
105191
|
+
routes.push(...manifest.staticRoutes);
|
|
105192
|
+
}
|
|
105193
|
+
if (manifest.contentRoutes && Array.isArray(manifest.contentRoutes)) {
|
|
105194
|
+
routes.push(...manifest.contentRoutes);
|
|
105195
|
+
}
|
|
105196
|
+
} catch {
|
|
105197
|
+
console.warn("⚠️ .reroute/manifest.json not found, scanning routes directory...");
|
|
105198
|
+
const routesPath = join16(cwd, ROUTES_DIR2);
|
|
105199
|
+
await scanForOgTemplates(routesPath, "", routes);
|
|
105200
|
+
await addContentRoutes(routesPath, routes);
|
|
105201
|
+
}
|
|
105202
|
+
return Array.from(new Set(routes)).sort();
|
|
105087
105203
|
}
|
|
105088
105204
|
function openInBrowser(url) {
|
|
105089
105205
|
const platform = process.platform;
|
|
@@ -105114,30 +105230,41 @@ ogImage: {
|
|
|
105114
105230
|
`);
|
|
105115
105231
|
const routes = await findRoutesWithOG(cwd);
|
|
105116
105232
|
if (routes.length === 0) {
|
|
105117
|
-
console.error("❌ No routes
|
|
105233
|
+
console.error("❌ No routes found for OG image generation");
|
|
105118
105234
|
console.log(`
|
|
105119
|
-
|
|
105235
|
+
Make sure you have:`);
|
|
105236
|
+
console.log(" 1. Routes defined in src/client/routes/");
|
|
105237
|
+
console.log(" 2. Run `reroute dev` or `reroute build` first to generate .reroute/manifest.json");
|
|
105238
|
+
console.log(`
|
|
105239
|
+
Or create [og].tsx files in your routes for custom OG templates.`);
|
|
105120
105240
|
process.exit(1);
|
|
105121
105241
|
}
|
|
105122
|
-
console.log(`Found ${routes.length} route(s)
|
|
105242
|
+
console.log(`Found ${routes.length} route(s) with OG images
|
|
105123
105243
|
`);
|
|
105244
|
+
const port = getPortFromConfig(config2.ogImage?.baseUrl);
|
|
105124
105245
|
let server2;
|
|
105125
105246
|
try {
|
|
105126
|
-
server2 = await
|
|
105247
|
+
server2 = await ensureServer(cwd, port);
|
|
105127
105248
|
} catch (error) {
|
|
105128
105249
|
console.error("❌ Failed to start server:", error);
|
|
105129
|
-
console.log("\nMake sure your server
|
|
105250
|
+
console.log("\nMake sure your dev server can start with `reroute dev`");
|
|
105130
105251
|
process.exit(1);
|
|
105131
105252
|
}
|
|
105132
|
-
const {
|
|
105253
|
+
const { process: serverProcess } = server2;
|
|
105133
105254
|
const cleanup = () => {
|
|
105134
105255
|
console.log(`
|
|
105135
105256
|
|
|
105136
|
-
\uD83D\uDED1 Shutting down server...`);
|
|
105137
|
-
|
|
105138
|
-
|
|
105139
|
-
|
|
105140
|
-
|
|
105257
|
+
\uD83D\uDED1 Shutting down dev server...`);
|
|
105258
|
+
if (serverProcess) {
|
|
105259
|
+
try {
|
|
105260
|
+
serverProcess.kill("SIGTERM");
|
|
105261
|
+
} catch {}
|
|
105262
|
+
}
|
|
105263
|
+
killProcessOnPort(port).then(() => {
|
|
105264
|
+
process.exit(0);
|
|
105265
|
+
}).catch(() => {
|
|
105266
|
+
process.exit(0);
|
|
105267
|
+
});
|
|
105141
105268
|
};
|
|
105142
105269
|
process.on("SIGINT", cleanup);
|
|
105143
105270
|
process.on("SIGTERM", cleanup);
|
|
@@ -105160,7 +105287,7 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105160
105287
|
parent: screen,
|
|
105161
105288
|
top: "center",
|
|
105162
105289
|
left: "center",
|
|
105163
|
-
width: "
|
|
105290
|
+
width: "95%",
|
|
105164
105291
|
height: "80%",
|
|
105165
105292
|
border: {
|
|
105166
105293
|
type: "line"
|
|
@@ -105177,8 +105304,15 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105177
105304
|
keys: true,
|
|
105178
105305
|
vi: true,
|
|
105179
105306
|
mouse: true,
|
|
105180
|
-
|
|
105181
|
-
|
|
105307
|
+
scrollbar: {
|
|
105308
|
+
ch: " ",
|
|
105309
|
+
style: {
|
|
105310
|
+
bg: "blue"
|
|
105311
|
+
}
|
|
105312
|
+
},
|
|
105313
|
+
label: ` Select a route to preview its OG image (${routes.length} routes) `,
|
|
105314
|
+
items: routes,
|
|
105315
|
+
tags: true
|
|
105182
105316
|
});
|
|
105183
105317
|
const statusBox = blessed.box({
|
|
105184
105318
|
parent: screen,
|
|
@@ -105192,12 +105326,11 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105192
105326
|
bg: "blue"
|
|
105193
105327
|
}
|
|
105194
105328
|
});
|
|
105195
|
-
let openedCount = 0;
|
|
105196
105329
|
list.on("select", (_item, index) => {
|
|
105197
105330
|
const selectedRoute = routes[index];
|
|
105198
105331
|
const ogUrl = `http://localhost:${port}/__reroute_og${selectedRoute === "/" ? "/index" : selectedRoute}.png`;
|
|
105199
|
-
|
|
105200
|
-
statusBox.setContent(`
|
|
105332
|
+
const displayUrl = ogUrl.length > 120 ? `${ogUrl.substring(0, 117)}...` : ogUrl;
|
|
105333
|
+
statusBox.setContent(` Opening: ${displayUrl} | Press Enter for more | q/Esc to quit `);
|
|
105201
105334
|
screen.render();
|
|
105202
105335
|
openInBrowser(ogUrl);
|
|
105203
105336
|
});
|
|
@@ -105314,7 +105447,7 @@ async function getVersionString2() {
|
|
|
105314
105447
|
}
|
|
105315
105448
|
async function getVersion2() {
|
|
105316
105449
|
if (true) {
|
|
105317
|
-
return "0.
|
|
105450
|
+
return "0.31.1";
|
|
105318
105451
|
}
|
|
105319
105452
|
const possiblePaths = [
|
|
105320
105453
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -105331,10 +105464,10 @@ async function getVersion2() {
|
|
|
105331
105464
|
}
|
|
105332
105465
|
async function getCommit2() {
|
|
105333
105466
|
if (true) {
|
|
105334
|
-
return "
|
|
105467
|
+
return "0cea34b";
|
|
105335
105468
|
}
|
|
105336
105469
|
return "dev";
|
|
105337
105470
|
}
|
|
105338
105471
|
main();
|
|
105339
105472
|
|
|
105340
|
-
//# debugId=
|
|
105473
|
+
//# debugId=1DE01775763BA80564756E2164756E21
|