reroute-js 0.20.3 → 0.20.4
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 +121 -110
- package/cli/bin.js.map +5 -4
- 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 +3 -3
- 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/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +24 -0
- package/cli/src/commands/lib/assets.d.ts.map +1 -0
- 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 +2 -2
- package/core/index.js.map +1 -1
- 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.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/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/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 +21 -26
- package/elysia/index.js.map +5 -4
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +15 -0
- package/elysia/src/libs/assets.d.ts.map +1 -0
- 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 +2 -1
- package/elysia/src/libs/index.d.ts.map +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.4
|
|
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.4";
|
|
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 "b55c7e7";
|
|
70
70
|
}
|
|
71
71
|
return "dev";
|
|
72
72
|
}
|
|
@@ -10636,35 +10636,62 @@ var init_start = __esm(() => {
|
|
|
10636
10636
|
init_log();
|
|
10637
10637
|
});
|
|
10638
10638
|
|
|
10639
|
+
// packages/cli/src/commands/lib/assets.ts
|
|
10640
|
+
import {
|
|
10641
|
+
cpSync,
|
|
10642
|
+
existsSync as existsSync8,
|
|
10643
|
+
mkdirSync,
|
|
10644
|
+
readdirSync
|
|
10645
|
+
} from "node:fs";
|
|
10646
|
+
import { join as join12 } from "node:path";
|
|
10647
|
+
function copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir) {
|
|
10648
|
+
if (!existsSync8(sourceAssetsDir)) {
|
|
10649
|
+
return 0;
|
|
10650
|
+
}
|
|
10651
|
+
const rerouteDir = join12(cwd, ".reroute");
|
|
10652
|
+
if (!existsSync8(rerouteDir)) {
|
|
10653
|
+
mkdirSync(rerouteDir, { recursive: true });
|
|
10654
|
+
}
|
|
10655
|
+
cpSync(sourceAssetsDir, rerouteAssetsDir, { recursive: true });
|
|
10656
|
+
return countFiles(rerouteAssetsDir);
|
|
10657
|
+
}
|
|
10658
|
+
function countFiles(dir) {
|
|
10659
|
+
let count = 0;
|
|
10660
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
10661
|
+
for (const entry of entries) {
|
|
10662
|
+
if (entry.isDirectory()) {
|
|
10663
|
+
count += countFiles(join12(dir, entry.name));
|
|
10664
|
+
} else {
|
|
10665
|
+
count++;
|
|
10666
|
+
}
|
|
10667
|
+
}
|
|
10668
|
+
return count;
|
|
10669
|
+
}
|
|
10670
|
+
var init_assets = () => {};
|
|
10671
|
+
|
|
10639
10672
|
// packages/cli/src/commands/build.ts
|
|
10640
10673
|
var exports_build = {};
|
|
10641
10674
|
__export(exports_build, {
|
|
10642
10675
|
default: () => build
|
|
10643
10676
|
});
|
|
10644
10677
|
import { spawn as spawn4 } from "node:child_process";
|
|
10645
|
-
import {
|
|
10646
|
-
|
|
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";
|
|
10678
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
10679
|
+
import { join as join13 } from "node:path";
|
|
10653
10680
|
function getRerouteCommand3() {
|
|
10654
|
-
const binPath =
|
|
10655
|
-
const isBunDev =
|
|
10681
|
+
const binPath = join13(import.meta.dir, "..", "..", "bin.ts");
|
|
10682
|
+
const isBunDev = existsSync9(binPath);
|
|
10656
10683
|
if (isBunDev) {
|
|
10657
10684
|
return `bun ${binPath}`;
|
|
10658
10685
|
}
|
|
10659
10686
|
const cwd = process.cwd();
|
|
10660
10687
|
const nodeModulesPaths = [
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10688
|
+
join13(cwd, "node_modules", ".bin", "reroute"),
|
|
10689
|
+
join13(cwd, "..", "node_modules", ".bin", "reroute"),
|
|
10690
|
+
join13(cwd, "..", "..", "node_modules", ".bin", "reroute"),
|
|
10691
|
+
join13(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
|
|
10665
10692
|
];
|
|
10666
10693
|
for (const binPath2 of nodeModulesPaths) {
|
|
10667
|
-
if (
|
|
10694
|
+
if (existsSync9(binPath2)) {
|
|
10668
10695
|
return binPath2;
|
|
10669
10696
|
}
|
|
10670
10697
|
}
|
|
@@ -10672,8 +10699,8 @@ function getRerouteCommand3() {
|
|
|
10672
10699
|
}
|
|
10673
10700
|
function getOutputName() {
|
|
10674
10701
|
const cwd = process.cwd();
|
|
10675
|
-
const packageJsonPath =
|
|
10676
|
-
if (
|
|
10702
|
+
const packageJsonPath = join13(cwd, "package.json");
|
|
10703
|
+
if (existsSync9(packageJsonPath)) {
|
|
10677
10704
|
try {
|
|
10678
10705
|
const packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
|
|
10679
10706
|
const name = packageJson.name;
|
|
@@ -10737,6 +10764,18 @@ async function build(args) {
|
|
|
10737
10764
|
});
|
|
10738
10765
|
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Generation complete
|
|
10739
10766
|
`));
|
|
10767
|
+
const cwd = process.cwd();
|
|
10768
|
+
const config2 = await loadConfig(cwd);
|
|
10769
|
+
const assetsPath = config2.options?.assets || "src/client";
|
|
10770
|
+
const sourceAssetsDir = join13(cwd, assetsPath, "assets");
|
|
10771
|
+
const rerouteAssetsDir = join13(cwd, ".reroute", "assets");
|
|
10772
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copying assets...
|
|
10773
|
+
`));
|
|
10774
|
+
const fileCount = copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir);
|
|
10775
|
+
if (fileCount > 0) {
|
|
10776
|
+
process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copied ${fileCount} assets to ${rerouteAssetsDir}
|
|
10777
|
+
`));
|
|
10778
|
+
}
|
|
10740
10779
|
process.stdout.write(`${colorizeLogPrefixAnsi(`[reroute/build] Building binary to ${outputPath}...`)}
|
|
10741
10780
|
`);
|
|
10742
10781
|
const buildArgs = [
|
|
@@ -10778,35 +10817,6 @@ async function build(args) {
|
|
|
10778
10817
|
reject(error);
|
|
10779
10818
|
});
|
|
10780
10819
|
});
|
|
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
|
-
}
|
|
10810
10820
|
} catch (error) {
|
|
10811
10821
|
process.stderr.write(`${colorizeLogPrefixAnsi("[reroute/build] Error: ") + String(error)}
|
|
10812
10822
|
`);
|
|
@@ -10815,6 +10825,7 @@ async function build(args) {
|
|
|
10815
10825
|
}
|
|
10816
10826
|
var init_build = __esm(() => {
|
|
10817
10827
|
init_core();
|
|
10828
|
+
init_assets();
|
|
10818
10829
|
init_log();
|
|
10819
10830
|
});
|
|
10820
10831
|
|
|
@@ -10823,23 +10834,23 @@ var exports_command = {};
|
|
|
10823
10834
|
__export(exports_command, {
|
|
10824
10835
|
getRerouteCommand: () => getRerouteCommand4
|
|
10825
10836
|
});
|
|
10826
|
-
import { existsSync as
|
|
10827
|
-
import { join as
|
|
10837
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
10838
|
+
import { join as join14 } from "node:path";
|
|
10828
10839
|
function getRerouteCommand4() {
|
|
10829
|
-
const binPath =
|
|
10830
|
-
const isBunDev =
|
|
10840
|
+
const binPath = join14(import.meta.dir, "..", "..", "bin.ts");
|
|
10841
|
+
const isBunDev = existsSync10(binPath);
|
|
10831
10842
|
if (isBunDev) {
|
|
10832
10843
|
return `bun ${binPath}`;
|
|
10833
10844
|
}
|
|
10834
10845
|
const cwd = process.cwd();
|
|
10835
10846
|
const nodeModulesPaths = [
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10847
|
+
join14(cwd, "node_modules", ".bin", "reroute"),
|
|
10848
|
+
join14(cwd, "..", "node_modules", ".bin", "reroute"),
|
|
10849
|
+
join14(cwd, "..", "..", "node_modules", ".bin", "reroute"),
|
|
10850
|
+
join14(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
|
|
10840
10851
|
];
|
|
10841
10852
|
for (const binPath2 of nodeModulesPaths) {
|
|
10842
|
-
if (
|
|
10853
|
+
if (existsSync10(binPath2)) {
|
|
10843
10854
|
return binPath2;
|
|
10844
10855
|
}
|
|
10845
10856
|
}
|
|
@@ -10852,24 +10863,24 @@ var exports_analyze = {};
|
|
|
10852
10863
|
__export(exports_analyze, {
|
|
10853
10864
|
default: () => analyze
|
|
10854
10865
|
});
|
|
10855
|
-
import { existsSync as
|
|
10866
|
+
import { existsSync as existsSync11, statSync } from "node:fs";
|
|
10856
10867
|
import { readdir as readdir6, readFile, stat as stat5, writeFile } from "node:fs/promises";
|
|
10857
|
-
import { basename as basename3, join as
|
|
10868
|
+
import { basename as basename3, join as join15, relative as relative3 } from "node:path";
|
|
10858
10869
|
import Table from "cli-table3";
|
|
10859
10870
|
async function findBundles(cwd) {
|
|
10860
10871
|
const bundles = [];
|
|
10861
|
-
const chunksDir =
|
|
10862
|
-
if (
|
|
10872
|
+
const chunksDir = join15(cwd, ".reroute", "chunks");
|
|
10873
|
+
if (existsSync11(chunksDir)) {
|
|
10863
10874
|
const collections2 = await readdir6(chunksDir, { withFileTypes: true });
|
|
10864
10875
|
for (const collection of collections2) {
|
|
10865
10876
|
if (!collection.isDirectory())
|
|
10866
10877
|
continue;
|
|
10867
|
-
const collectionDir =
|
|
10878
|
+
const collectionDir = join15(chunksDir, collection.name);
|
|
10868
10879
|
const files = await readdir6(collectionDir);
|
|
10869
10880
|
for (const file of files) {
|
|
10870
10881
|
if (!file.endsWith(".js"))
|
|
10871
10882
|
continue;
|
|
10872
|
-
const filePath =
|
|
10883
|
+
const filePath = join15(collectionDir, file);
|
|
10873
10884
|
const stats = await stat5(filePath);
|
|
10874
10885
|
const content2 = await Bun.file(filePath).arrayBuffer();
|
|
10875
10886
|
const gzippedSize = Bun.gzipSync(new Uint8Array(content2)).length;
|
|
@@ -10884,11 +10895,11 @@ async function findBundles(cwd) {
|
|
|
10884
10895
|
}
|
|
10885
10896
|
}
|
|
10886
10897
|
}
|
|
10887
|
-
const distDir =
|
|
10888
|
-
if (
|
|
10898
|
+
const distDir = join15(cwd, "dist");
|
|
10899
|
+
if (existsSync11(distDir)) {
|
|
10889
10900
|
const files = await readdir6(distDir);
|
|
10890
10901
|
for (const file of files) {
|
|
10891
|
-
const filePath =
|
|
10902
|
+
const filePath = join15(distDir, file);
|
|
10892
10903
|
const stats = statSync(filePath);
|
|
10893
10904
|
if (stats.isFile() && !file.endsWith(".map") && !file.endsWith(".d.ts")) {
|
|
10894
10905
|
const content2 = await Bun.file(filePath).arrayBuffer();
|
|
@@ -10908,13 +10919,13 @@ async function findBundles(cwd) {
|
|
|
10908
10919
|
}
|
|
10909
10920
|
async function findBrowserEntry(cwd) {
|
|
10910
10921
|
try {
|
|
10911
|
-
const clientDir =
|
|
10912
|
-
const tsxEntry =
|
|
10913
|
-
const tsEntry =
|
|
10922
|
+
const clientDir = join15(cwd, "src", "client");
|
|
10923
|
+
const tsxEntry = join15(clientDir, "index.tsx");
|
|
10924
|
+
const tsEntry = join15(clientDir, "index.ts");
|
|
10914
10925
|
let sourceEntry = null;
|
|
10915
|
-
if (
|
|
10926
|
+
if (existsSync11(tsxEntry)) {
|
|
10916
10927
|
sourceEntry = tsxEntry;
|
|
10917
|
-
} else if (
|
|
10928
|
+
} else if (existsSync11(tsEntry)) {
|
|
10918
10929
|
sourceEntry = tsEntry;
|
|
10919
10930
|
}
|
|
10920
10931
|
if (!sourceEntry)
|
|
@@ -10943,12 +10954,12 @@ async function findBrowserEntry(cwd) {
|
|
|
10943
10954
|
console.warn("[reroute/analyze] Browser build produced no outputs");
|
|
10944
10955
|
return null;
|
|
10945
10956
|
}
|
|
10946
|
-
const tempDir =
|
|
10957
|
+
const tempDir = join15(cwd, ".reroute", "browser");
|
|
10947
10958
|
await import("node:fs/promises").then((fs) => fs.mkdir(tempDir, { recursive: true }));
|
|
10948
10959
|
const output = result.outputs[0];
|
|
10949
10960
|
const code = await output.text();
|
|
10950
10961
|
const actualHash = await generateContentHash2(code);
|
|
10951
|
-
const bundlePath =
|
|
10962
|
+
const bundlePath = join15(tempDir, `index.${actualHash}.js`);
|
|
10952
10963
|
await writeFile(bundlePath, code, "utf-8");
|
|
10953
10964
|
const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
|
|
10954
10965
|
if (mapOutput) {
|
|
@@ -11000,8 +11011,8 @@ function calculateStats(bundles) {
|
|
|
11000
11011
|
}
|
|
11001
11012
|
async function getInstalledPackageSizes(cwd) {
|
|
11002
11013
|
const packageSizes = new Map;
|
|
11003
|
-
const nodeModulesDir =
|
|
11004
|
-
if (!
|
|
11014
|
+
const nodeModulesDir = join15(cwd, "node_modules");
|
|
11015
|
+
if (!existsSync11(nodeModulesDir))
|
|
11005
11016
|
return packageSizes;
|
|
11006
11017
|
try {
|
|
11007
11018
|
const { execSync } = await import("node:child_process");
|
|
@@ -11039,7 +11050,7 @@ async function getInstalledPackageSizes(cwd) {
|
|
|
11039
11050
|
}
|
|
11040
11051
|
async function buildDependencyTree(entryPath, cwd) {
|
|
11041
11052
|
try {
|
|
11042
|
-
if (!
|
|
11053
|
+
if (!existsSync11(entryPath))
|
|
11043
11054
|
return null;
|
|
11044
11055
|
const root = {
|
|
11045
11056
|
name: basename3(entryPath),
|
|
@@ -11059,7 +11070,7 @@ async function buildDependencyTree(entryPath, cwd) {
|
|
|
11059
11070
|
if (!pkgNode) {
|
|
11060
11071
|
pkgNode = {
|
|
11061
11072
|
name: pkgName || "unknown",
|
|
11062
|
-
path:
|
|
11073
|
+
path: join15(cwd, "node_modules", pkgName || ""),
|
|
11063
11074
|
size: 0,
|
|
11064
11075
|
children: []
|
|
11065
11076
|
};
|
|
@@ -11080,7 +11091,7 @@ async function buildDependencyTree(entryPath, cwd) {
|
|
|
11080
11091
|
if (!child) {
|
|
11081
11092
|
child = {
|
|
11082
11093
|
name: part,
|
|
11083
|
-
path:
|
|
11094
|
+
path: join15(cwd, ...parts.slice(0, i + 1)),
|
|
11084
11095
|
size: 0,
|
|
11085
11096
|
children: []
|
|
11086
11097
|
};
|
|
@@ -11104,7 +11115,7 @@ async function buildDependencyTree(entryPath, cwd) {
|
|
|
11104
11115
|
const modulePattern = /\/\/\s*(.+?\.(?:ts|tsx|js|jsx|mjs|cjs))\s*$/gm;
|
|
11105
11116
|
const nodeModulesNode = {
|
|
11106
11117
|
name: "node_modules",
|
|
11107
|
-
path:
|
|
11118
|
+
path: join15(cwd, "node_modules"),
|
|
11108
11119
|
size: 0,
|
|
11109
11120
|
children: []
|
|
11110
11121
|
};
|
|
@@ -11170,7 +11181,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
|
|
|
11170
11181
|
if (sourcePath.startsWith("/") || sourcePath.match(/^[A-Za-z]:\\/))
|
|
11171
11182
|
return sourcePath;
|
|
11172
11183
|
const bundleDir = bundlePath.substring(0, bundlePath.lastIndexOf("/"));
|
|
11173
|
-
return
|
|
11184
|
+
return join15(bundleDir, sourceRoot || "", sourcePath);
|
|
11174
11185
|
}, computeSizes = function(node) {
|
|
11175
11186
|
if (node.children && node.children.length > 0) {
|
|
11176
11187
|
node.size = node.children.reduce((s, c) => s + computeSizes(c), 0);
|
|
@@ -11178,7 +11189,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
|
|
|
11178
11189
|
return node.size;
|
|
11179
11190
|
};
|
|
11180
11191
|
const mapPath = `${bundlePath}.map`;
|
|
11181
|
-
if (!
|
|
11192
|
+
if (!existsSync11(mapPath))
|
|
11182
11193
|
return null;
|
|
11183
11194
|
const [bundle, mapJson] = await Promise.all([
|
|
11184
11195
|
readFile(bundlePath, "utf-8"),
|
|
@@ -11242,7 +11253,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
|
|
|
11242
11253
|
};
|
|
11243
11254
|
const nodeModulesNode = {
|
|
11244
11255
|
name: "node_modules",
|
|
11245
|
-
path:
|
|
11256
|
+
path: join15(cwd, "node_modules"),
|
|
11246
11257
|
size: 0,
|
|
11247
11258
|
children: []
|
|
11248
11259
|
};
|
|
@@ -11282,7 +11293,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
|
|
|
11282
11293
|
if (!pkgNode) {
|
|
11283
11294
|
pkgNode = {
|
|
11284
11295
|
name: pkgName || "unknown",
|
|
11285
|
-
path:
|
|
11296
|
+
path: join15(cwd, "node_modules", pkgName || ""),
|
|
11286
11297
|
size: 0,
|
|
11287
11298
|
children: []
|
|
11288
11299
|
};
|
|
@@ -11303,7 +11314,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
|
|
|
11303
11314
|
if (!child) {
|
|
11304
11315
|
child = {
|
|
11305
11316
|
name: part,
|
|
11306
|
-
path:
|
|
11317
|
+
path: join15(cwd, ...parts.slice(0, i2 + 1)),
|
|
11307
11318
|
size: 0,
|
|
11308
11319
|
children: []
|
|
11309
11320
|
};
|
|
@@ -11333,11 +11344,11 @@ async function generateHTMLReport(stats, depTree, mainInfo, browserDepTree, brow
|
|
|
11333
11344
|
let actualServerBinarySize = null;
|
|
11334
11345
|
let actualServerBinaryGzipped = null;
|
|
11335
11346
|
try {
|
|
11336
|
-
const distDir =
|
|
11337
|
-
if (
|
|
11347
|
+
const distDir = join15(process.cwd(), "dist");
|
|
11348
|
+
if (existsSync11(distDir)) {
|
|
11338
11349
|
const files = await readdir6(distDir);
|
|
11339
11350
|
for (const file of files) {
|
|
11340
|
-
const filePath =
|
|
11351
|
+
const filePath = join15(distDir, file);
|
|
11341
11352
|
const stats2 = statSync(filePath);
|
|
11342
11353
|
if (stats2.isFile() && !file.includes(".")) {
|
|
11343
11354
|
actualServerBinarySize = stats2.size;
|
|
@@ -12819,11 +12830,11 @@ async function printConsoleReport(stats, depTree, mainInfo, browserDepTree, brow
|
|
|
12819
12830
|
let actualServerBinarySize = null;
|
|
12820
12831
|
let actualServerBinaryGzipped = null;
|
|
12821
12832
|
try {
|
|
12822
|
-
const distDir =
|
|
12823
|
-
if (
|
|
12833
|
+
const distDir = join15(process.cwd(), "dist");
|
|
12834
|
+
if (existsSync11(distDir)) {
|
|
12824
12835
|
const files = await readdir6(distDir);
|
|
12825
12836
|
for (const file of files) {
|
|
12826
|
-
const filePath =
|
|
12837
|
+
const filePath = join15(distDir, file);
|
|
12827
12838
|
const stats2 = statSync(filePath);
|
|
12828
12839
|
if (stats2.isFile() && !file.includes(".")) {
|
|
12829
12840
|
actualServerBinarySize = stats2.size;
|
|
@@ -12857,8 +12868,8 @@ async function analyze(args) {
|
|
|
12857
12868
|
const isProd = isProductionMode(args);
|
|
12858
12869
|
const searchIndex = args.indexOf("--search");
|
|
12859
12870
|
const initialSearch = searchIndex !== -1 && args[searchIndex + 1] ? args[searchIndex + 1] : "";
|
|
12860
|
-
const rerouteIndexPath =
|
|
12861
|
-
if (!
|
|
12871
|
+
const rerouteIndexPath = join15(cwd, ".reroute", "index.ts");
|
|
12872
|
+
if (!existsSync11(rerouteIndexPath)) {
|
|
12862
12873
|
console.log(colorizeLogPrefixAnsi(`[reroute/analyze] .reroute artifacts not found, running build...
|
|
12863
12874
|
`));
|
|
12864
12875
|
const { spawn: spawn5 } = await import("node:child_process");
|
|
@@ -12920,12 +12931,12 @@ async function analyze(args) {
|
|
|
12920
12931
|
let entry = null;
|
|
12921
12932
|
let depTree = null;
|
|
12922
12933
|
let mainInfo = null;
|
|
12923
|
-
const srcEntry =
|
|
12924
|
-
if (
|
|
12934
|
+
const srcEntry = join15(cwd, "src", "index.ts");
|
|
12935
|
+
if (existsSync11(srcEntry)) {
|
|
12925
12936
|
console.log(colorizeLogPrefixAnsi(`[reroute/analyze] Building server binary for analysis...
|
|
12926
12937
|
`));
|
|
12927
12938
|
const { mkdir: mkdir3 } = await import("node:fs/promises");
|
|
12928
|
-
const serverAnalysisDir =
|
|
12939
|
+
const serverAnalysisDir = join15(cwd, ".reroute", "server");
|
|
12929
12940
|
await mkdir3(serverAnalysisDir, { recursive: true });
|
|
12930
12941
|
const result = await Bun.build({
|
|
12931
12942
|
entrypoints: [srcEntry],
|
|
@@ -12938,7 +12949,7 @@ async function analyze(args) {
|
|
|
12938
12949
|
if (result.success && result.outputs.length > 0) {
|
|
12939
12950
|
const output = result.outputs[0];
|
|
12940
12951
|
const code = await output.text();
|
|
12941
|
-
const analysisEntry =
|
|
12952
|
+
const analysisEntry = join15(serverAnalysisDir, "index.js");
|
|
12942
12953
|
await writeFile(analysisEntry, code, "utf-8");
|
|
12943
12954
|
const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
|
|
12944
12955
|
if (mapOutput) {
|
|
@@ -12956,8 +12967,8 @@ async function analyze(args) {
|
|
|
12956
12967
|
`));
|
|
12957
12968
|
const installedSizes = await getInstalledPackageSizes(cwd);
|
|
12958
12969
|
if (depTree) {
|
|
12959
|
-
const packageJsonPath =
|
|
12960
|
-
if (
|
|
12970
|
+
const packageJsonPath = join15(cwd, "package.json");
|
|
12971
|
+
if (existsSync11(packageJsonPath)) {
|
|
12961
12972
|
try {
|
|
12962
12973
|
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
12963
12974
|
const runtimeDeps = packageJson.dependencies || {};
|
|
@@ -12968,7 +12979,7 @@ async function analyze(args) {
|
|
|
12968
12979
|
if (!trackedPkgs.has(pkgName) && installedSizes.has(pkgName)) {
|
|
12969
12980
|
nodeModulesNode.children?.push({
|
|
12970
12981
|
name: pkgName,
|
|
12971
|
-
path:
|
|
12982
|
+
path: join15(cwd, "node_modules", pkgName),
|
|
12972
12983
|
size: installedSizes.get(pkgName) || 0
|
|
12973
12984
|
});
|
|
12974
12985
|
}
|
|
@@ -12999,10 +13010,10 @@ async function analyze(args) {
|
|
|
12999
13010
|
const fullOutput = args.includes("--full");
|
|
13000
13011
|
await printConsoleReport(stats, depTree, mainInfo, browserDepTree, browserInfo, fullOutput);
|
|
13001
13012
|
if (outputHtml || openBrowser) {
|
|
13002
|
-
const htmlPath =
|
|
13013
|
+
const htmlPath = join15(cwd, ".reroute", "analysis.html");
|
|
13003
13014
|
const html2 = await generateHTMLReport(stats, depTree, mainInfo, browserDepTree, browserInfo, initialSearch);
|
|
13004
13015
|
const { mkdir: mkdir3 } = await import("node:fs/promises");
|
|
13005
|
-
await mkdir3(
|
|
13016
|
+
await mkdir3(join15(cwd, ".reroute"), { recursive: true });
|
|
13006
13017
|
await writeFile(htmlPath, html2, "utf-8");
|
|
13007
13018
|
console.log(colorizeLogPrefixAnsi(`[reroute/analyze] HTML report generated: ${relative3(cwd, htmlPath)}
|
|
13008
13019
|
`));
|
|
@@ -13066,7 +13077,7 @@ __export(exports_og, {
|
|
|
13066
13077
|
});
|
|
13067
13078
|
import { spawn as spawn5 } from "node:child_process";
|
|
13068
13079
|
import { readdir as readdir7 } from "node:fs/promises";
|
|
13069
|
-
import { join as
|
|
13080
|
+
import { join as join16 } from "node:path";
|
|
13070
13081
|
async function findAvailablePort() {
|
|
13071
13082
|
const server = Bun.serve({
|
|
13072
13083
|
port: 0,
|
|
@@ -13120,14 +13131,14 @@ Error output:`, errorOutput);
|
|
|
13120
13131
|
return { port, process: proc };
|
|
13121
13132
|
}
|
|
13122
13133
|
async function findRoutesWithOG(cwd) {
|
|
13123
|
-
const routesPath =
|
|
13134
|
+
const routesPath = join16(cwd, ROUTES_DIR2);
|
|
13124
13135
|
const routes = [];
|
|
13125
13136
|
async function scan(dir, base = "") {
|
|
13126
13137
|
try {
|
|
13127
13138
|
const entries = await readdir7(dir, { withFileTypes: true });
|
|
13128
13139
|
for (const entry of entries) {
|
|
13129
|
-
const fullPath =
|
|
13130
|
-
const relativePath =
|
|
13140
|
+
const fullPath = join16(dir, entry.name);
|
|
13141
|
+
const relativePath = join16(base, entry.name);
|
|
13131
13142
|
if (entry.isDirectory()) {
|
|
13132
13143
|
if (entry.name === "content")
|
|
13133
13144
|
continue;
|
|
@@ -13144,7 +13155,7 @@ async function findRoutesWithOG(cwd) {
|
|
|
13144
13155
|
const entries = await readdir7(routesPath, { withFileTypes: true });
|
|
13145
13156
|
for (const entry of entries) {
|
|
13146
13157
|
if (entry.isDirectory()) {
|
|
13147
|
-
const contentDir =
|
|
13158
|
+
const contentDir = join16(routesPath, entry.name, "content");
|
|
13148
13159
|
try {
|
|
13149
13160
|
const contentFiles = await readdir7(contentDir);
|
|
13150
13161
|
if (contentFiles.length > 0) {
|
|
@@ -13389,7 +13400,7 @@ async function getVersionString2() {
|
|
|
13389
13400
|
}
|
|
13390
13401
|
async function getVersion2() {
|
|
13391
13402
|
if (true) {
|
|
13392
|
-
return "0.20.
|
|
13403
|
+
return "0.20.4";
|
|
13393
13404
|
}
|
|
13394
13405
|
const possiblePaths = [
|
|
13395
13406
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -13406,10 +13417,10 @@ async function getVersion2() {
|
|
|
13406
13417
|
}
|
|
13407
13418
|
async function getCommit2() {
|
|
13408
13419
|
if (true) {
|
|
13409
|
-
return "
|
|
13420
|
+
return "b55c7e7";
|
|
13410
13421
|
}
|
|
13411
13422
|
return "dev";
|
|
13412
13423
|
}
|
|
13413
13424
|
main();
|
|
13414
13425
|
|
|
13415
|
-
//# debugId=
|
|
13426
|
+
//# debugId=87B653DED7FC6A5164756E2164756E21
|