reroute-js 0.30.2 → 0.31.0
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/README.md +0 -1
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +167 -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 -2
- 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 -7
- package/telemetry/react.js.map +3 -3
- 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/react/telemetry.d.ts.map +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/README.md
CHANGED
|
@@ -1588,7 +1588,6 @@ new Elysia()
|
|
|
1588
1588
|
# Browser telemetry packages
|
|
1589
1589
|
bun add @opentelemetry/api \
|
|
1590
1590
|
@opentelemetry/auto-instrumentations-web \
|
|
1591
|
-
@opentelemetry/context-zone \
|
|
1592
1591
|
@opentelemetry/exporter-trace-otlp-http \
|
|
1593
1592
|
@opentelemetry/instrumentation \
|
|
1594
1593
|
@opentelemetry/resources \
|
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.0
|
|
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.0";
|
|
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 "6490560";
|
|
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)$/, "");
|
|
@@ -7153,6 +7172,19 @@ async function generate(cwd, args = [], options = {}) {
|
|
|
7153
7172
|
const appPath = config2.options.app.startsWith(".") ? `../${config2.options.app}` : config2.options.app;
|
|
7154
7173
|
indexLines.push(`import AppComponent from '${appPath}';`);
|
|
7155
7174
|
}
|
|
7175
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7176
|
+
const ogTemplatePath = config2.ogImage.defaultTemplate.startsWith(".") ? `../${config2.ogImage.defaultTemplate}` : config2.ogImage.defaultTemplate;
|
|
7177
|
+
indexLines.push(`import OGTemplate from '${ogTemplatePath}';`);
|
|
7178
|
+
}
|
|
7179
|
+
const ogFiles = await scanOgFiles(join9(cwd, ROUTES_DIR));
|
|
7180
|
+
const ogImports = [];
|
|
7181
|
+
for (let i = 0;i < ogFiles.length; i++) {
|
|
7182
|
+
const ogFile = ogFiles[i];
|
|
7183
|
+
const importName = `OGRoute${i}`;
|
|
7184
|
+
const importPath = `../src/client/routes/${ogFile.replace(/\.(tsx|ts)$/, "")}`;
|
|
7185
|
+
indexLines.push(`import ${importName} from '${importPath}';`);
|
|
7186
|
+
ogImports.push({ path: ogFile, name: importName });
|
|
7187
|
+
}
|
|
7156
7188
|
indexLines.push("");
|
|
7157
7189
|
indexLines.push("export const bundle = {");
|
|
7158
7190
|
indexLines.push(" layouts,");
|
|
@@ -7165,12 +7197,31 @@ async function generate(cwd, args = [], options = {}) {
|
|
|
7165
7197
|
if (config2.options?.app) {
|
|
7166
7198
|
indexLines.push(" AppComponent,");
|
|
7167
7199
|
}
|
|
7200
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7201
|
+
indexLines.push(" OGTemplate,");
|
|
7202
|
+
}
|
|
7168
7203
|
indexLines.push("} as const;");
|
|
7169
7204
|
if (config2.options?.app) {
|
|
7170
7205
|
indexLines.push("");
|
|
7171
7206
|
indexLines.push("// Set global for compiled binary SSR support");
|
|
7172
7207
|
indexLines.push("(globalThis as any).__REROUTE_APP_COMPONENT__ = AppComponent;");
|
|
7173
7208
|
}
|
|
7209
|
+
if (config2.ogImage?.defaultTemplate && config2.ogImage.defaultTemplate !== "default") {
|
|
7210
|
+
indexLines.push("");
|
|
7211
|
+
indexLines.push("// Set global for compiled binary OG template support");
|
|
7212
|
+
indexLines.push("(globalThis as any).__REROUTE_OG_TEMPLATE__ = OGTemplate;");
|
|
7213
|
+
}
|
|
7214
|
+
if (ogImports.length > 0) {
|
|
7215
|
+
indexLines.push("");
|
|
7216
|
+
indexLines.push("// Route-specific OG templates for compiled binary support");
|
|
7217
|
+
indexLines.push("(globalThis as any).__REROUTE_OG_ROUTES__ = {");
|
|
7218
|
+
for (const { path: path3, name } of ogImports) {
|
|
7219
|
+
const routePath = path3.replace(/\/?\[og]\.(tsx|ts)$/, "").replace(/\\/g, "/");
|
|
7220
|
+
const normalizedPath = routePath ? `/${routePath}` : "/";
|
|
7221
|
+
indexLines.push(` '${normalizedPath}': ${name},`);
|
|
7222
|
+
}
|
|
7223
|
+
indexLines.push("};");
|
|
7224
|
+
}
|
|
7174
7225
|
const templatePath = join9(cwd, "src", "client", "index.html");
|
|
7175
7226
|
try {
|
|
7176
7227
|
const templateContent = await Bun.file(templatePath).text();
|
|
@@ -102560,6 +102611,17 @@ function cleanDistFolder(cwd) {
|
|
|
102560
102611
|
rmSync(distDir, { recursive: true });
|
|
102561
102612
|
}
|
|
102562
102613
|
}
|
|
102614
|
+
async function cleanRerouteFolder(cwd) {
|
|
102615
|
+
const rerouteDir = join13(cwd, ".reroute");
|
|
102616
|
+
if (existsSync9(rerouteDir)) {
|
|
102617
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Cleaning .reroute folder...
|
|
102618
|
+
`));
|
|
102619
|
+
rmSync(rerouteDir, { recursive: true, force: true });
|
|
102620
|
+
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
102621
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] ✓ .reroute folder cleaned
|
|
102622
|
+
`));
|
|
102623
|
+
}
|
|
102624
|
+
}
|
|
102563
102625
|
function createOutputHandler(genBuffer) {
|
|
102564
102626
|
return (data) => {
|
|
102565
102627
|
const text = genBuffer.current + data.toString();
|
|
@@ -102616,7 +102678,12 @@ async function copyAssets(cwd) {
|
|
|
102616
102678
|
}
|
|
102617
102679
|
}
|
|
102618
102680
|
async function buildBundle(cwd, buildArgs) {
|
|
102619
|
-
const external = [
|
|
102681
|
+
const external = [
|
|
102682
|
+
"sharp",
|
|
102683
|
+
"@opentelemetry/*",
|
|
102684
|
+
"@vercel/og",
|
|
102685
|
+
...buildArgs.externalArgs
|
|
102686
|
+
];
|
|
102620
102687
|
const buildResult = await Bun.build({
|
|
102621
102688
|
entrypoints: [join13(cwd, ".reroute/entry.ts")],
|
|
102622
102689
|
target: "bun",
|
|
@@ -102701,6 +102768,7 @@ async function build(args) {
|
|
|
102701
102768
|
try {
|
|
102702
102769
|
const buildStartTime = performance.now();
|
|
102703
102770
|
cleanDistFolder(cwd);
|
|
102771
|
+
await cleanRerouteFolder(cwd);
|
|
102704
102772
|
const rerouteCmd = getRerouteCommand3();
|
|
102705
102773
|
const useShell = rerouteCmd.includes(" ");
|
|
102706
102774
|
await runGenCommand(rerouteCmd, useShell, buildArgs.noCompression);
|
|
@@ -104986,24 +105054,46 @@ __export(exports_og, {
|
|
|
104986
105054
|
import { spawn as spawn5 } from "node:child_process";
|
|
104987
105055
|
import { readdir as readdir7 } from "node:fs/promises";
|
|
104988
105056
|
import { join as join16 } from "node:path";
|
|
104989
|
-
|
|
104990
|
-
|
|
104991
|
-
|
|
104992
|
-
|
|
104993
|
-
|
|
104994
|
-
|
|
104995
|
-
|
|
104996
|
-
|
|
104997
|
-
throw new Error("Failed to allocate port");
|
|
105057
|
+
function getPortFromConfig(baseUrl) {
|
|
105058
|
+
if (!baseUrl)
|
|
105059
|
+
return 3000;
|
|
105060
|
+
try {
|
|
105061
|
+
const url = new URL(baseUrl);
|
|
105062
|
+
return url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80;
|
|
105063
|
+
} catch {
|
|
105064
|
+
return 3000;
|
|
104998
105065
|
}
|
|
104999
|
-
return port;
|
|
105000
105066
|
}
|
|
105001
|
-
async function
|
|
105002
|
-
|
|
105003
|
-
|
|
105004
|
-
|
|
105067
|
+
async function killProcessOnPort(port) {
|
|
105068
|
+
try {
|
|
105069
|
+
const proc = spawn5("bunx", ["kill-port", String(port)], {
|
|
105070
|
+
stdio: "ignore"
|
|
105071
|
+
});
|
|
105072
|
+
await new Promise((resolve2) => {
|
|
105073
|
+
proc.on("close", () => resolve2());
|
|
105074
|
+
});
|
|
105075
|
+
} catch {}
|
|
105076
|
+
}
|
|
105077
|
+
async function isServerRunning(port) {
|
|
105078
|
+
try {
|
|
105079
|
+
const response = await fetch(`http://localhost:${port}`, {
|
|
105080
|
+
signal: AbortSignal.timeout(1000)
|
|
105081
|
+
});
|
|
105082
|
+
return response.ok || response.status < 500;
|
|
105083
|
+
} catch {
|
|
105084
|
+
return false;
|
|
105085
|
+
}
|
|
105086
|
+
}
|
|
105087
|
+
async function ensureServer(cwd, port) {
|
|
105088
|
+
const alreadyRunning = await isServerRunning(port);
|
|
105089
|
+
if (alreadyRunning) {
|
|
105090
|
+
console.log(`✅ Dev server already running at http://localhost:${port}
|
|
105091
|
+
`);
|
|
105092
|
+
return { port, process: null, wasAlreadyRunning: true };
|
|
105093
|
+
}
|
|
105094
|
+
console.log(`\uD83D\uDE80 Starting dev server on port ${port}...`);
|
|
105095
|
+
const proc = spawn5("reroute", ["dev"], {
|
|
105005
105096
|
cwd,
|
|
105006
|
-
env: { ...process.env, PORT: String(port) },
|
|
105007
105097
|
stdio: ["ignore", "pipe", "pipe"],
|
|
105008
105098
|
detached: false
|
|
105009
105099
|
});
|
|
@@ -105012,7 +105102,7 @@ async function startServer(cwd) {
|
|
|
105012
105102
|
proc.stderr?.on("data", (data) => {
|
|
105013
105103
|
errorOutput += data.toString();
|
|
105014
105104
|
});
|
|
105015
|
-
for (let i = 0;i <
|
|
105105
|
+
for (let i = 0;i < 60; i++) {
|
|
105016
105106
|
await Bun.sleep(500);
|
|
105017
105107
|
try {
|
|
105018
105108
|
const response = await fetch(`http://localhost:${port}`, {
|
|
@@ -105034,9 +105124,9 @@ async function startServer(cwd) {
|
|
|
105034
105124
|
console.error(`
|
|
105035
105125
|
Error output:`, errorOutput);
|
|
105036
105126
|
}
|
|
105037
|
-
throw new Error("Server failed to start within
|
|
105127
|
+
throw new Error("Server failed to start within 30 seconds");
|
|
105038
105128
|
}
|
|
105039
|
-
return { port, process: proc };
|
|
105129
|
+
return { port, process: proc, wasAlreadyRunning: false };
|
|
105040
105130
|
}
|
|
105041
105131
|
async function scanForOgTemplates(dir, base, routes) {
|
|
105042
105132
|
try {
|
|
@@ -105079,11 +105169,24 @@ async function addContentRoutes(routesPath, routes) {
|
|
|
105079
105169
|
} catch {}
|
|
105080
105170
|
}
|
|
105081
105171
|
async function findRoutesWithOG(cwd) {
|
|
105082
|
-
const routesPath = join16(cwd, ROUTES_DIR2);
|
|
105083
105172
|
const routes = [];
|
|
105084
|
-
|
|
105085
|
-
|
|
105086
|
-
|
|
105173
|
+
try {
|
|
105174
|
+
const manifestPath = join16(cwd, ".reroute", "manifest.json");
|
|
105175
|
+
const manifestFile = Bun.file(manifestPath);
|
|
105176
|
+
const manifest = await manifestFile.json();
|
|
105177
|
+
if (manifest.staticRoutes && Array.isArray(manifest.staticRoutes)) {
|
|
105178
|
+
routes.push(...manifest.staticRoutes);
|
|
105179
|
+
}
|
|
105180
|
+
if (manifest.contentRoutes && Array.isArray(manifest.contentRoutes)) {
|
|
105181
|
+
routes.push(...manifest.contentRoutes);
|
|
105182
|
+
}
|
|
105183
|
+
} catch {
|
|
105184
|
+
console.warn("⚠️ .reroute/manifest.json not found, scanning routes directory...");
|
|
105185
|
+
const routesPath = join16(cwd, ROUTES_DIR2);
|
|
105186
|
+
await scanForOgTemplates(routesPath, "", routes);
|
|
105187
|
+
await addContentRoutes(routesPath, routes);
|
|
105188
|
+
}
|
|
105189
|
+
return Array.from(new Set(routes)).sort();
|
|
105087
105190
|
}
|
|
105088
105191
|
function openInBrowser(url) {
|
|
105089
105192
|
const platform = process.platform;
|
|
@@ -105114,30 +105217,41 @@ ogImage: {
|
|
|
105114
105217
|
`);
|
|
105115
105218
|
const routes = await findRoutesWithOG(cwd);
|
|
105116
105219
|
if (routes.length === 0) {
|
|
105117
|
-
console.error("❌ No routes
|
|
105220
|
+
console.error("❌ No routes found for OG image generation");
|
|
105118
105221
|
console.log(`
|
|
105119
|
-
|
|
105222
|
+
Make sure you have:`);
|
|
105223
|
+
console.log(" 1. Routes defined in src/client/routes/");
|
|
105224
|
+
console.log(" 2. Run `reroute dev` or `reroute build` first to generate .reroute/manifest.json");
|
|
105225
|
+
console.log(`
|
|
105226
|
+
Or create [og].tsx files in your routes for custom OG templates.`);
|
|
105120
105227
|
process.exit(1);
|
|
105121
105228
|
}
|
|
105122
|
-
console.log(`Found ${routes.length} route(s)
|
|
105229
|
+
console.log(`Found ${routes.length} route(s) with OG images
|
|
105123
105230
|
`);
|
|
105231
|
+
const port = getPortFromConfig(config2.ogImage?.baseUrl);
|
|
105124
105232
|
let server2;
|
|
105125
105233
|
try {
|
|
105126
|
-
server2 = await
|
|
105234
|
+
server2 = await ensureServer(cwd, port);
|
|
105127
105235
|
} catch (error) {
|
|
105128
105236
|
console.error("❌ Failed to start server:", error);
|
|
105129
|
-
console.log("\nMake sure your server
|
|
105237
|
+
console.log("\nMake sure your dev server can start with `reroute dev`");
|
|
105130
105238
|
process.exit(1);
|
|
105131
105239
|
}
|
|
105132
|
-
const {
|
|
105240
|
+
const { process: serverProcess } = server2;
|
|
105133
105241
|
const cleanup = () => {
|
|
105134
105242
|
console.log(`
|
|
105135
105243
|
|
|
105136
|
-
\uD83D\uDED1 Shutting down server...`);
|
|
105137
|
-
|
|
105138
|
-
|
|
105139
|
-
|
|
105140
|
-
|
|
105244
|
+
\uD83D\uDED1 Shutting down dev server...`);
|
|
105245
|
+
if (serverProcess) {
|
|
105246
|
+
try {
|
|
105247
|
+
serverProcess.kill("SIGTERM");
|
|
105248
|
+
} catch {}
|
|
105249
|
+
}
|
|
105250
|
+
killProcessOnPort(port).then(() => {
|
|
105251
|
+
process.exit(0);
|
|
105252
|
+
}).catch(() => {
|
|
105253
|
+
process.exit(0);
|
|
105254
|
+
});
|
|
105141
105255
|
};
|
|
105142
105256
|
process.on("SIGINT", cleanup);
|
|
105143
105257
|
process.on("SIGTERM", cleanup);
|
|
@@ -105160,7 +105274,7 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105160
105274
|
parent: screen,
|
|
105161
105275
|
top: "center",
|
|
105162
105276
|
left: "center",
|
|
105163
|
-
width: "
|
|
105277
|
+
width: "95%",
|
|
105164
105278
|
height: "80%",
|
|
105165
105279
|
border: {
|
|
105166
105280
|
type: "line"
|
|
@@ -105177,8 +105291,15 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105177
105291
|
keys: true,
|
|
105178
105292
|
vi: true,
|
|
105179
105293
|
mouse: true,
|
|
105180
|
-
|
|
105181
|
-
|
|
105294
|
+
scrollbar: {
|
|
105295
|
+
ch: " ",
|
|
105296
|
+
style: {
|
|
105297
|
+
bg: "blue"
|
|
105298
|
+
}
|
|
105299
|
+
},
|
|
105300
|
+
label: ` Select a route to preview its OG image (${routes.length} routes) `,
|
|
105301
|
+
items: routes,
|
|
105302
|
+
tags: true
|
|
105182
105303
|
});
|
|
105183
105304
|
const statusBox = blessed.box({
|
|
105184
105305
|
parent: screen,
|
|
@@ -105192,12 +105313,11 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
105192
105313
|
bg: "blue"
|
|
105193
105314
|
}
|
|
105194
105315
|
});
|
|
105195
|
-
let openedCount = 0;
|
|
105196
105316
|
list.on("select", (_item, index) => {
|
|
105197
105317
|
const selectedRoute = routes[index];
|
|
105198
105318
|
const ogUrl = `http://localhost:${port}/__reroute_og${selectedRoute === "/" ? "/index" : selectedRoute}.png`;
|
|
105199
|
-
|
|
105200
|
-
statusBox.setContent(`
|
|
105319
|
+
const displayUrl = ogUrl.length > 120 ? `${ogUrl.substring(0, 117)}...` : ogUrl;
|
|
105320
|
+
statusBox.setContent(` Opening: ${displayUrl} | Press Enter for more | q/Esc to quit `);
|
|
105201
105321
|
screen.render();
|
|
105202
105322
|
openInBrowser(ogUrl);
|
|
105203
105323
|
});
|
|
@@ -105314,7 +105434,7 @@ async function getVersionString2() {
|
|
|
105314
105434
|
}
|
|
105315
105435
|
async function getVersion2() {
|
|
105316
105436
|
if (true) {
|
|
105317
|
-
return "0.
|
|
105437
|
+
return "0.31.0";
|
|
105318
105438
|
}
|
|
105319
105439
|
const possiblePaths = [
|
|
105320
105440
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -105331,10 +105451,10 @@ async function getVersion2() {
|
|
|
105331
105451
|
}
|
|
105332
105452
|
async function getCommit2() {
|
|
105333
105453
|
if (true) {
|
|
105334
|
-
return "
|
|
105454
|
+
return "6490560";
|
|
105335
105455
|
}
|
|
105336
105456
|
return "dev";
|
|
105337
105457
|
}
|
|
105338
105458
|
main();
|
|
105339
105459
|
|
|
105340
|
-
//# debugId=
|
|
105460
|
+
//# debugId=9B655B997A9BB54164756E2164756E21
|