reroute-js 0.9.0 → 0.9.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.
Files changed (124) hide show
  1. package/_/basic/package.json +1 -0
  2. package/_/basic/src/client/index.html +0 -1
  3. package/_/blog/package.json +1 -0
  4. package/_/store/package.json +1 -0
  5. package/cli/bin.d.ts +1 -1
  6. package/cli/bin.js +559 -675
  7. package/cli/bin.js.map +19 -24
  8. package/cli/index.d.ts +1 -1
  9. package/cli/index.js +48 -25
  10. package/cli/index.js.map +5 -5
  11. package/cli/src/cli.d.ts +1 -1
  12. package/cli/src/commands/analyze.d.ts +1 -1
  13. package/cli/src/commands/build.d.ts +3 -4
  14. package/cli/src/commands/build.d.ts.map +1 -1
  15. package/cli/src/commands/dev.d.ts +2 -3
  16. package/cli/src/commands/dev.d.ts.map +1 -1
  17. package/cli/src/commands/gen.d.ts +1 -1
  18. package/cli/src/commands/gen.d.ts.map +1 -1
  19. package/cli/src/commands/init.d.ts +1 -1
  20. package/cli/src/commands/start.d.ts +3 -4
  21. package/cli/src/commands/start.d.ts.map +1 -1
  22. package/cli/src/libs/command.d.ts +1 -1
  23. package/cli/src/libs/index.d.ts +1 -1
  24. package/cli/src/libs/log.d.ts +1 -1
  25. package/cli/src/libs/log.d.ts.map +1 -1
  26. package/cli/src/libs/markdown-processor.d.ts +2 -1
  27. package/cli/src/libs/markdown-processor.d.ts.map +1 -1
  28. package/cli/src/libs/markdown.d.ts +1 -1
  29. package/cli/src/libs/production.d.ts +1 -1
  30. package/cli/src/libs/server.d.ts +18 -0
  31. package/cli/src/libs/server.d.ts.map +1 -0
  32. package/cli/src/libs/tailwind.d.ts +2 -2
  33. package/cli/src/libs/tailwind.d.ts.map +1 -1
  34. package/cli/src/libs/version.d.ts +1 -1
  35. package/core/index.d.ts +1 -1
  36. package/core/index.js +99 -410
  37. package/core/index.js.map +7 -10
  38. package/core/src/bundler/hash.d.ts +1 -1
  39. package/core/src/bundler/index.d.ts +1 -2
  40. package/core/src/bundler/index.d.ts.map +1 -1
  41. package/core/src/content/discovery.d.ts +1 -3
  42. package/core/src/content/discovery.d.ts.map +1 -1
  43. package/core/src/content/index.d.ts +1 -2
  44. package/core/src/content/index.d.ts.map +1 -1
  45. package/core/src/content/metadata.d.ts +1 -1
  46. package/core/src/index.d.ts +1 -1
  47. package/core/src/ssr/data.d.ts +1 -1
  48. package/core/src/ssr/index.d.ts +1 -1
  49. package/core/src/ssr/modules.d.ts +1 -1
  50. package/core/src/ssr/render.d.ts +1 -1
  51. package/core/src/ssr/render.d.ts.map +1 -1
  52. package/core/src/ssr/seed.d.ts +1 -1
  53. package/core/src/template/html.d.ts +1 -1
  54. package/core/src/template/index.d.ts +1 -1
  55. package/core/src/types.d.ts +2 -22
  56. package/core/src/types.d.ts.map +1 -1
  57. package/core/src/utils/cache.d.ts +1 -1
  58. package/core/src/utils/compression.d.ts +1 -1
  59. package/core/src/utils/compression.d.ts.map +1 -1
  60. package/core/src/utils/index.d.ts +1 -1
  61. package/core/src/utils/mime.d.ts +1 -1
  62. package/core/src/utils/path.d.ts +1 -1
  63. package/elysia/index.d.ts +1 -1
  64. package/elysia/index.js +301 -774
  65. package/elysia/index.js.map +14 -17
  66. package/elysia/src/index.d.ts +1 -1
  67. package/elysia/src/libs/cache.d.ts +14 -0
  68. package/elysia/src/libs/cache.d.ts.map +1 -0
  69. package/elysia/src/libs/http.d.ts +1 -1
  70. package/elysia/src/libs/image.d.ts +1 -1
  71. package/elysia/src/libs/image.d.ts.map +1 -1
  72. package/elysia/src/plugin.d.ts +1 -1
  73. package/elysia/src/plugin.d.ts.map +1 -1
  74. package/elysia/src/routes/artifacts.d.ts +9 -2
  75. package/elysia/src/routes/artifacts.d.ts.map +1 -1
  76. package/elysia/src/routes/content.d.ts +3 -2
  77. package/elysia/src/routes/content.d.ts.map +1 -1
  78. package/elysia/src/routes/dev.d.ts +1 -1
  79. package/elysia/src/routes/dev.d.ts.map +1 -1
  80. package/elysia/src/routes/image.d.ts +1 -1
  81. package/elysia/src/routes/ssr.d.ts +1 -1
  82. package/elysia/src/routes/ssr.d.ts.map +1 -1
  83. package/elysia/src/routes/static.d.ts +2 -5
  84. package/elysia/src/routes/static.d.ts.map +1 -1
  85. package/elysia/src/types.d.ts +10 -3
  86. package/elysia/src/types.d.ts.map +1 -1
  87. package/package.json +4 -4
  88. package/react/index.d.ts +1 -1
  89. package/react/index.js +80 -65
  90. package/react/index.js.map +5 -4
  91. package/react/src/components/ClientOnly.d.ts +1 -1
  92. package/react/src/components/ContentRoute.d.ts +1 -1
  93. package/react/src/components/Image.d.ts +1 -1
  94. package/react/src/components/Link.d.ts +1 -1
  95. package/react/src/components/Markdown.d.ts +1 -1
  96. package/react/src/components/Outlet.d.ts +1 -1
  97. package/react/src/components/index.d.ts +1 -1
  98. package/react/src/hooks/index.d.ts +1 -1
  99. package/react/src/hooks/useContent.d.ts +1 -1
  100. package/react/src/hooks/useData.d.ts +1 -1
  101. package/react/src/hooks/useNavigate.d.ts +1 -1
  102. package/react/src/hooks/useParams.d.ts +1 -1
  103. package/react/src/hooks/useRouter.d.ts +1 -1
  104. package/react/src/hooks/useSearchParams.d.ts +1 -1
  105. package/react/src/index.d.ts +1 -1
  106. package/react/src/providers/ContentProvider.d.ts +1 -1
  107. package/react/src/providers/RerouteProvider.d.ts +1 -1
  108. package/react/src/providers/RouterProvider.d.ts +1 -1
  109. package/react/src/providers/index.d.ts +1 -1
  110. package/react/src/types/any.d.ts +1 -1
  111. package/react/src/types/index.d.ts +1 -1
  112. package/react/src/types/router.d.ts +1 -1
  113. package/react/src/utils/content.d.ts +1 -1
  114. package/react/src/utils/head.d.ts +1 -1
  115. package/react/src/utils/index.d.ts +2 -1
  116. package/react/src/utils/index.d.ts.map +1 -1
  117. package/react/src/utils/lazy-route.d.ts +41 -0
  118. package/react/src/utils/lazy-route.d.ts.map +1 -0
  119. package/cli/src/commands/boot.d.ts +0 -18
  120. package/cli/src/commands/boot.d.ts.map +0 -1
  121. package/core/src/bundler/transpile.d.ts +0 -14
  122. package/core/src/bundler/transpile.d.ts.map +0 -1
  123. package/core/src/content/registry.d.ts +0 -11
  124. package/core/src/content/registry.d.ts.map +0 -1
package/core/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v0.9.0
2
+ * reroute-js v0.9.1
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2025 stewones <hi@stewan.io>
@@ -7,27 +7,21 @@
7
7
  *
8
8
  * Built with Bun <3
9
9
  */
10
- var __defProp = Object.defineProperty;
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, {
14
- get: all[name],
15
- enumerable: true,
16
- configurable: true,
17
- set: (newValue) => all[name] = () => newValue
18
- });
19
- };
10
+
11
+ // packages/core/src/bundler/hash.ts
12
+ async function generateContentHash(content) {
13
+ const data = new TextEncoder().encode(content);
14
+ const buf = await crypto.subtle.digest("SHA-256", data);
15
+ let hex = "";
16
+ for (const b of new Uint8Array(buf))
17
+ hex += b.toString(16).padStart(2, "0");
18
+ return hex.slice(0, 8);
19
+ }
20
+ // packages/core/src/content/discovery.ts
21
+ import { readdir, stat } from "node:fs/promises";
20
22
 
21
23
  // packages/core/src/utils/path.ts
22
- var exports_path = {};
23
- __export(exports_path, {
24
- stripStart: () => stripStart,
25
- stripEnd: () => stripEnd,
26
- join: () => join2,
27
- extname: () => extname,
28
- basename: () => basename
29
- });
30
- function join2(...parts) {
24
+ function join(...parts) {
31
25
  return parts.join("/").replace(/\/+/g, "/");
32
26
  }
33
27
  function extname(p) {
@@ -45,277 +39,57 @@ function stripEnd(p, ch) {
45
39
  return p.endsWith(ch) ? p.slice(0, -ch.length) : p;
46
40
  }
47
41
 
48
- // packages/core/src/bundler/hash.ts
49
- async function generateContentHash(content) {
50
- const data = new TextEncoder().encode(content);
51
- const buf = await crypto.subtle.digest("SHA-256", data);
52
- let hex = "";
53
- for (const b of new Uint8Array(buf))
54
- hex += b.toString(16).padStart(2, "0");
55
- return hex.slice(0, 8);
56
- }
57
- // packages/cli/src/libs/tailwind.ts
58
- import { spawn } from "node:child_process";
59
- import { existsSync, readFileSync } from "node:fs";
60
- import { join } from "node:path";
61
- function isTailwindAvailable(cwd) {
62
- const packageJsonPath = join(cwd, "package.json");
63
- if (!existsSync(packageJsonPath)) {
64
- return false;
65
- }
66
- try {
67
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
68
- const deps = {
69
- ...packageJson.dependencies,
70
- ...packageJson.devDependencies
71
- };
72
- return "@tailwindcss/cli" in deps;
73
- } catch {
74
- return false;
75
- }
76
- }
77
- function getTailwindPaths(cwd) {
78
- const input = join(cwd, "src/client/theme.css");
79
- const output = join(cwd, ".reroute/theme.css");
80
- return { input, output };
81
- }
82
- function hasTailwindInput(cwd) {
83
- const { input } = getTailwindPaths(cwd);
84
- if (!existsSync(input)) {
85
- return false;
86
- }
42
+ // packages/core/src/content/discovery.ts
43
+ async function listContentFiles(dir, baseRel) {
44
+ const out = [];
87
45
  try {
88
- const content = readFileSync(input, "utf-8");
89
- return content.includes("tailwindcss");
90
- } catch {
91
- return false;
92
- }
93
- }
94
- function resolveTailwindBin(cwd) {
95
- const pathsToTry = [
96
- join(cwd, "../node_modules/.bin/tailwindcss"),
97
- join(cwd, "../../node_modules/.bin/tailwindcss"),
98
- join(cwd, "../../../node_modules/.bin/tailwindcss")
99
- ];
100
- for (const binPath of pathsToTry) {
101
- if (existsSync(binPath)) {
102
- return binPath;
103
- }
104
- }
105
- return join(cwd, "node_modules/.bin/tailwindcss");
106
- }
107
- async function buildTailwind(cwd) {
108
- const { input, output } = getTailwindPaths(cwd);
109
- return new Promise((resolve, reject) => {
110
- const tailwindBin = resolveTailwindBin(cwd);
111
- const args = ["-i", input, "-o", output];
112
- console.log(`[reroute/tailwind] build start: -i ${input} -o ${output}`);
113
- const tailwind = spawn(tailwindBin, args, {
114
- cwd,
115
- stdio: "pipe"
116
- });
117
- tailwind.stdout?.on("data", (data) => {
118
- const line = data.toString().trim();
119
- if (line) {
120
- console.log(`[reroute/tailwind] ${line}`);
121
- }
122
- });
123
- tailwind.stderr?.on("data", (data) => {
124
- const line = data.toString().trim();
125
- if (line) {
126
- console.log(`[reroute/tailwind] ${line}`);
127
- }
128
- });
129
- tailwind.on("close", (code) => {
130
- if (code === 0) {
131
- console.log("[reroute/tailwind] build done");
132
- resolve();
133
- } else {
134
- reject(new Error(`Tailwind CSS build failed with code ${code}`));
46
+ const entries = await readdir(dir, { withFileTypes: true });
47
+ for (const entry of entries) {
48
+ const full = join(dir, entry.name);
49
+ const rel = join(baseRel, entry.name);
50
+ if (entry.isDirectory()) {
51
+ const nested = await listContentFiles(full, rel);
52
+ out.push(...nested);
53
+ } else if (entry.isFile()) {
54
+ if (/\.(tsx|ts)$/.test(entry.name) && !entry.name.startsWith("_")) {
55
+ out.push(rel);
56
+ }
135
57
  }
136
- });
137
- tailwind.on("error", (error) => {
138
- reject(error);
139
- });
140
- });
141
- }
142
- async function buildTailwindIfConfigured(cwd) {
143
- try {
144
- if (isTailwindAvailable(cwd) && hasTailwindInput(cwd)) {
145
- await buildTailwind(cwd);
146
- return true;
147
58
  }
148
- return false;
149
- } catch (e) {
150
- console.warn("[reroute/tailwind] build failed:", e);
151
- return true;
152
- }
153
- }
154
- // packages/core/src/bundler/transpile.ts
155
- var entryUrlToStaticDeps = new Map;
156
- function isWatchMode() {
157
- try {
158
- return Array.isArray(process.execArgv) && process.execArgv.includes("--watch") || Array.isArray(process.argv) && process.argv.includes("--watch");
159
- } catch {
160
- return false;
161
- }
59
+ } catch {}
60
+ return out;
162
61
  }
163
- async function transpileFile(filePath, originalPath, options, bundleCache) {
164
- const src = await Bun.file(filePath).text();
165
- const cacheKey = `${filePath}-${await generateContentHash(src)}`;
166
- if (bundleCache.has(cacheKey)) {
167
- return bundleCache.get(cacheKey);
168
- }
169
- console.log(`[reroute] Building ${originalPath}${options.minify ? " (minified)" : ""}...`);
170
- try {
171
- if (isWatchMode()) {
172
- const cwd = typeof process !== "undefined" && process.cwd ? process.cwd() : "";
173
- if (cwd) {
174
- await buildTailwindIfConfigured(cwd);
175
- }
176
- }
177
- } catch (e) {
178
- console.warn("[reroute/tailwind] rebuild failed:", e);
179
- }
180
- async function doBuild(sm) {
181
- return await Bun.build({
182
- entrypoints: [filePath],
183
- target: "browser",
184
- format: "esm",
185
- minify: options.minify,
186
- splitting: true,
187
- sourcemap: sm,
188
- jsx: {
189
- runtime: "automatic",
190
- importSource: "react",
191
- development: !options.minify
192
- },
193
- define: {
194
- "process.env.NODE_ENV": options.minify ? '"production"' : '"development"',
195
- __DEV__: options.minify ? "false" : "true",
196
- "import.meta.env.MODE": options.minify ? '"production"' : '"development"'
197
- },
198
- ...options.minify ? { drop: ["console", "debugger"] } : {}
199
- });
200
- }
201
- let result;
62
+ async function discoverCollections(clientDir) {
63
+ const root = join(clientDir, "routes");
64
+ const collections = new Set;
202
65
  try {
203
- result = await doBuild(options.sourcemap ? "external" : "none");
204
- } catch (error) {
205
- console.warn(`[reroute] Build errored for ${originalPath} (sourcemap external). Retrying without sourcemap...`, error);
206
- result = await doBuild("none");
207
- }
208
- if (!result.success) {
209
- console.error(`[reroute] Failed to build ${filePath}`);
210
- for (const log2 of result.logs)
211
- console.error(log2);
212
- throw new Error(`Failed to transpile ${filePath}`);
213
- }
214
- const outputs = await Promise.all(result.outputs.map(async (o) => ({
215
- path: o.path,
216
- text: await o.text()
217
- })));
218
- const entryBase = basename(originalPath, extname(originalPath));
219
- let entry = outputs.find((o) => o.path.endsWith(`${entryBase}.js`));
220
- if (!entry) {
221
- entry = outputs.filter((o) => o.path.endsWith(".js")).sort((a, b) => b.text.length - a.text.length)[0];
222
- }
223
- if (!entry) {
224
- throw new Error(`[reroute] No JS output generated for ${originalPath}`);
225
- }
226
- const code = entry.text;
227
- let sourceMap;
228
- if (options.sourcemap && result.outputs.length > 1) {
229
- const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
230
- if (mapOutput) {
231
- sourceMap = await mapOutput.text();
232
- }
233
- }
234
- const contentHash = await generateContentHash(code);
235
- const chunks = outputs.filter((o) => o !== entry && o.path.endsWith(".js")).map((o) => ({
236
- fileName: basename(o.path),
237
- code: o.text,
238
- hash: "",
239
- isEntry: false,
240
- imports: []
241
- }));
242
- for (const c of chunks) {
243
- c.hash = await generateContentHash(c.code);
244
- try {
245
- const bn = c.fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
246
- const re = new RegExp(`["'\`]((?:\\./)?${bn})["'\`]`, "g");
247
- const matches = [...code.matchAll(re)];
248
- if (matches.length) {
249
- c.isEntry = false;
66
+ const entries = await readdir(root, { withFileTypes: true });
67
+ for (const entry of entries) {
68
+ if (entry.isDirectory()) {
69
+ const contentDir = join(root, entry.name, "content");
70
+ try {
71
+ await stat(contentDir);
72
+ collections.add(entry.name);
73
+ } catch {}
250
74
  }
251
- } catch {}
252
- }
253
- const staticDepNames = [];
254
- try {
255
- for (const c of chunks) {
256
- const bn = c.fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
257
- const re = new RegExp(`["'\`]((?:\\./)?${bn})["'\`]`, "g");
258
- if (re.test(code))
259
- staticDepNames.push(c.fileName);
260
75
  }
261
76
  } catch {}
262
- const bundleInfo = {
263
- hash: contentHash,
264
- code,
265
- sourceMap,
266
- chunks
267
- };
268
- bundleCache.set(cacheKey, bundleInfo);
269
- const sizeKB = (code.length / 1024).toFixed(2);
270
- const gzippedSize = Bun.gzipSync(new TextEncoder().encode(code)).length;
271
- const gzippedKB = (gzippedSize / 1024).toFixed(2);
272
- console.log(`[reroute] Built ${originalPath} -> ${sizeKB} KB (${gzippedKB} KB gzipped)`);
273
- return bundleInfo;
274
- }
275
- async function getBundleUrlsFor(modules, clientDir, prefix, options, bundleCache) {
276
- const mods = Array.isArray(modules) ? modules : [modules];
277
- const urls = [];
278
- const { join: join3 } = await Promise.resolve().then(() => exports_path);
279
- for (const mod of mods) {
280
- const rel = mod.replace(/^\.\//, "");
281
- const fullPath = join3(clientDir, rel);
282
- try {
283
- const bundleInfo = await transpileFile(fullPath, rel, options, bundleCache);
284
- const base = basename(rel, extname(rel));
285
- const entryUrl = `${prefix}/${base}.${bundleInfo.hash}.js`;
286
- urls.push(entryUrl);
287
- try {
288
- const depNames = Array.isArray(bundleInfo.chunks) ? bundleInfo.chunks.map((c) => c.fileName).filter((name) => new RegExp(`["'\`]((?:\\./)?${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["'\`]`, "g").test(bundleInfo.code)) : [];
289
- const depUrls = depNames.map((n) => `${prefix}/${n}`.replace(/\/+/g, "/"));
290
- entryUrlToStaticDeps.set(entryUrl, depUrls);
291
- } catch {}
292
- } catch (error) {
293
- console.error(`[reroute] Error getting bundle URL for ${rel}:`, error);
294
- urls.push(`${prefix}/${rel}`);
295
- }
296
- }
297
- return urls;
298
- }
299
- function getStaticDepsForUrl(entryUrl) {
300
- return entryUrlToStaticDeps.get(entryUrl) || [];
77
+ return Array.from(collections);
301
78
  }
302
- // packages/core/src/content/discovery.ts
303
- import { readdir, stat as stat2 } from "node:fs/promises";
304
-
305
79
  // packages/core/src/content/metadata.ts
306
- import { stat } from "node:fs/promises";
80
+ import { stat as stat2 } from "node:fs/promises";
307
81
  import { pathToFileURL } from "node:url";
308
- async function getContentMeta(absPath, isWatchMode2) {
82
+ async function getContentMeta(absPath, isWatchMode) {
309
83
  try {
310
84
  const url = pathToFileURL(absPath).href;
311
- const mod = await import(`${url}${isWatchMode2 ? `?t=${Date.now()}` : ""}`);
85
+ const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
312
86
  const meta = mod.meta || mod.frontmatter || {};
313
87
  if (meta && typeof meta === "object")
314
88
  return meta;
315
89
  return {};
316
90
  } catch {
317
91
  try {
318
- const s = await stat(absPath);
92
+ const s = await stat2(absPath);
319
93
  return { date: new Date(s.mtimeMs).toISOString() };
320
94
  } catch {
321
95
  return {};
@@ -339,84 +113,13 @@ ${parts.join(`
339
113
  function escapeHtml(input) {
340
114
  return input.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
341
115
  }
342
-
343
- // packages/core/src/content/discovery.ts
344
- async function listContentFiles(dir, baseRel) {
345
- const out = [];
346
- try {
347
- const entries = await readdir(dir, { withFileTypes: true });
348
- for (const entry of entries) {
349
- const full = join2(dir, entry.name);
350
- const rel = join2(baseRel, entry.name);
351
- if (entry.isDirectory()) {
352
- const nested = await listContentFiles(full, rel);
353
- out.push(...nested);
354
- } else if (entry.isFile()) {
355
- if (/\.(tsx|ts)$/.test(entry.name) && !entry.name.startsWith("_")) {
356
- out.push(rel);
357
- }
358
- }
359
- }
360
- } catch {}
361
- return out;
362
- }
363
- async function buildContentDTOs(collectionPath, clientDir, prefix, isWatchMode2) {
364
- const normalized = stripStart(stripEnd(collectionPath, "/"), "/");
365
- const contentRelDir = join2("routes", normalized, "content");
366
- const contentAbsDir = join2(clientDir, contentRelDir);
367
- const files = await listContentFiles(contentAbsDir, "");
368
- const items = [];
369
- for (const rel of files) {
370
- const fullRelPath = join2(contentRelDir, rel);
371
- const absPath = join2(clientDir, fullRelPath);
372
- const noExt = rel.replace(/\.(tsx|ts)$/, "");
373
- const name = basename(noExt);
374
- const moduleUrl = `${prefix}/${fullRelPath}`.replace(/\/+/g, "/");
375
- const meta = await getContentMeta(absPath, isWatchMode2);
376
- const href = `/${normalized}/${name}`.replace(/\\+/g, "/");
377
- items.push({
378
- slug: noExt,
379
- name,
380
- path: fullRelPath,
381
- module: moduleUrl,
382
- meta,
383
- href
384
- });
385
- }
386
- return items;
387
- }
388
- async function discoverCollections(clientDir) {
389
- const root = join2(clientDir, "routes");
390
- const collections = new Set;
391
- try {
392
- const entries = await readdir(root, { withFileTypes: true });
393
- for (const entry of entries) {
394
- if (entry.isDirectory()) {
395
- const contentDir = join2(root, entry.name, "content");
396
- try {
397
- await stat2(contentDir);
398
- collections.add(entry.name);
399
- } catch {}
400
- }
401
- }
402
- } catch {}
403
- return Array.from(collections);
404
- }
405
- // packages/core/src/content/registry.ts
406
- async function generateContentRegistry(cwd) {
407
- try {
408
- const p = join2(cwd, ".reroute", "content.ts");
409
- const exists = await Bun.file(p).exists();
410
- console.log(exists ? "[reroute] Content registry up-to-date" : "[reroute] Warning: .reroute/content.ts not found");
411
- } catch {}
412
- }
413
116
  // packages/core/src/ssr/data.ts
414
117
  import { pathToFileURL as pathToFileURL3 } from "node:url";
415
118
 
416
119
  // packages/core/src/ssr/modules.ts
417
120
  import { readdir as readdir2, stat as stat3 } from "node:fs/promises";
418
121
  import { pathToFileURL as pathToFileURL2 } from "node:url";
419
- async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2) {
122
+ async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode) {
420
123
  try {
421
124
  const parts = pathname.split("/").filter(Boolean);
422
125
  if (parts.length < 2)
@@ -424,20 +127,20 @@ async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2
424
127
  const collection = parts[0];
425
128
  const name = parts[1];
426
129
  try {
427
- const registryPath = join2(cwd, ".reroute", "content.ts");
428
- const reg = await import(pathToFileURL2(registryPath).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
130
+ const registryPath = join(cwd, ".reroute", "content.ts");
131
+ const reg = await import(pathToFileURL2(registryPath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
429
132
  const get = reg?.getContentEntry;
430
133
  const entry = typeof get === "function" ? get(collection, name) : undefined;
431
134
  const moduleUrl = entry?.module;
432
135
  if (moduleUrl?.endsWith(".js")) {
433
- const abs = join2(cwd, moduleUrl.replace(/^\//, ""));
434
- const href = pathToFileURL2(abs).href + (isWatchMode2 ? `?t=${Date.now()}` : "");
136
+ const abs = join(cwd, moduleUrl.replace(/^\//, ""));
137
+ const href = pathToFileURL2(abs).href + (isWatchMode ? `?t=${Date.now()}` : "");
435
138
  const mod = await import(href);
436
139
  return mod;
437
140
  }
438
141
  } catch {}
439
142
  try {
440
- const chunkDir = join2(cwd, ".reroute", "chunks", collection);
143
+ const chunkDir = join(cwd, ".reroute", "chunks", collection);
441
144
  const files = await readdir2(chunkDir);
442
145
  const matches = files.filter((n) => n.startsWith(`${name}.`) && n.endsWith(".js"));
443
146
  if (matches.length) {
@@ -445,22 +148,22 @@ async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2
445
148
  let latestM = 0;
446
149
  for (const f of matches) {
447
150
  try {
448
- const s = await stat3(join2(chunkDir, f));
151
+ const s = await stat3(join(chunkDir, f));
449
152
  if (s.mtimeMs >= latestM) {
450
153
  latestM = s.mtimeMs;
451
154
  latest = f;
452
155
  }
453
156
  } catch {}
454
157
  }
455
- const absChunk = join2(chunkDir, latest);
456
- const href = pathToFileURL2(absChunk).href + (isWatchMode2 ? `?t=${Date.now()}` : "");
158
+ const absChunk = join(chunkDir, latest);
159
+ const href = pathToFileURL2(absChunk).href + (isWatchMode ? `?t=${Date.now()}` : "");
457
160
  const mod = await import(href);
458
161
  return mod;
459
162
  }
460
163
  } catch {}
461
164
  try {
462
- const srcTsx = join2(clientDir, "routes", collection, "content", `${name}.tsx`);
463
- const srcTs = join2(clientDir, "routes", collection, "content", `${name}.ts`);
165
+ const srcTsx = join(clientDir, "routes", collection, "content", `${name}.tsx`);
166
+ const srcTs = join(clientDir, "routes", collection, "content", `${name}.ts`);
464
167
  let absSrc = null;
465
168
  if (await Bun.file(srcTsx).exists())
466
169
  absSrc = srcTsx;
@@ -468,7 +171,7 @@ async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2
468
171
  absSrc = srcTs;
469
172
  if (absSrc) {
470
173
  const href = pathToFileURL2(absSrc).href;
471
- const mod = await (isWatchMode2 ? import(`${href}?t=${Date.now()}`) : import(href));
174
+ const mod = await (isWatchMode ? import(`${href}?t=${Date.now()}`) : import(href));
472
175
  return mod;
473
176
  }
474
177
  } catch {}
@@ -477,7 +180,7 @@ async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2
477
180
  }
478
181
 
479
182
  // packages/core/src/ssr/seed.ts
480
- async function seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode2) {
183
+ async function seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode) {
481
184
  try {
482
185
  const parts = pathname.split("/").filter(Boolean);
483
186
  if (parts.length < 2)
@@ -485,7 +188,7 @@ async function seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode2) {
485
188
  const collection = parts[0];
486
189
  const name = parts[1];
487
190
  const key = `${collection}:${name}`;
488
- const mod = await importContentModuleForPath(pathname, clientDir, cwd, isWatchMode2);
191
+ const mod = await importContentModuleForPath(pathname, clientDir, cwd, isWatchMode);
489
192
  if (!mod)
490
193
  return;
491
194
  const C = mod.default || mod;
@@ -505,9 +208,9 @@ async function seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode2) {
505
208
 
506
209
  // packages/core/src/ssr/data.ts
507
210
  async function computeSSRDataForPath(params) {
508
- const { pathname, clientDir, cwd, isWatchMode: isWatchMode2 } = params;
211
+ const { pathname, clientDir, cwd, isWatchMode } = params;
509
212
  try {
510
- await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode2);
213
+ await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode);
511
214
  } catch {}
512
215
  try {
513
216
  const parts = pathname.split("/").filter(Boolean);
@@ -522,15 +225,15 @@ async function computeSSRDataForPath(params) {
522
225
  }
523
226
  } catch {}
524
227
  try {
525
- const routesPath = join2(cwd, ".reroute", "routes.ts");
526
- const m = await import(pathToFileURL3(routesPath).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
228
+ const routesPath = join(cwd, ".reroute", "routes.ts");
229
+ const m = await import(pathToFileURL3(routesPath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
527
230
  const match = typeof m.matchRoute === "function" ? m.matchRoute(pathname) : null;
528
231
  const r = match?.route;
529
232
  const paramsValue = match?.params || {};
530
233
  if (r && typeof r.path === "string") {
531
234
  try {
532
- const abs = join2(clientDir, "routes", String(r.path));
533
- const mod = await import(pathToFileURL3(abs).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
235
+ const abs = join(clientDir, "routes", String(r.path));
236
+ const mod = await import(pathToFileURL3(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
534
237
  const ssr = mod?.ssr;
535
238
  const dataFn = ssr?.data;
536
239
  if (typeof dataFn === "function") {
@@ -545,7 +248,7 @@ async function computeSSRDataForPath(params) {
545
248
  import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
546
249
  import { pathToFileURL as pathToFileURL4 } from "node:url";
547
250
 
548
- // node_modules/dedent/dist/dedent.mjs
251
+ // node_modules/.bun/dedent@1.7.0/node_modules/dedent/dist/dedent.mjs
549
252
  function ownKeys(object, enumerableOnly) {
550
253
  var keys = Object.keys(object);
551
254
  if (Object.getOwnPropertySymbols) {
@@ -667,7 +370,7 @@ import { renderToString } from "react-dom/server";
667
370
 
668
371
  // packages/core/src/template/html.ts
669
372
  async function loadIndexHtml(clientDir) {
670
- const templatePath = join2(clientDir, "index.html");
373
+ const templatePath = join(clientDir, "index.html");
671
374
  try {
672
375
  const content = await Bun.file(templatePath).text();
673
376
  return content;
@@ -744,7 +447,7 @@ async function renderSSRDocument(options) {
744
447
  rootComponent,
745
448
  clientDir,
746
449
  cwd,
747
- isWatchMode: isWatchMode2,
450
+ isWatchMode,
748
451
  bundleUrl,
749
452
  head = "",
750
453
  lang = "en",
@@ -760,15 +463,6 @@ async function renderSSRDocument(options) {
760
463
  <link rel="modulepreload" href="${bundleUrl}" />`;
761
464
  }
762
465
  } catch {}
763
- try {
764
- const staticDeps = getStaticDepsForUrl(bundleUrl);
765
- if (Array.isArray(staticDeps) && staticDeps.length) {
766
- for (const dep of staticDeps) {
767
- extraHead += `
768
- <link rel="modulepreload" href="${dep}" />`;
769
- }
770
- }
771
- } catch {}
772
466
  let statusOverride;
773
467
  try {
774
468
  globalThis.__REROUTE_SSR_ACCESSED__ = {};
@@ -781,7 +475,7 @@ async function renderSSRDocument(options) {
781
475
  let modulePath = "";
782
476
  let isContentCollection = false;
783
477
  try {
784
- const maybeDir = join2(clientDir, "routes", collection, "content");
478
+ const maybeDir = join(clientDir, "routes", collection, "content");
785
479
  const s = await stat4(maybeDir);
786
480
  isContentCollection = typeof s?.isDirectory === "function" ? s.isDirectory() : true;
787
481
  } catch {
@@ -791,8 +485,8 @@ async function renderSSRDocument(options) {
791
485
  throw new Error("skip-content-preload");
792
486
  }
793
487
  try {
794
- const registryPath = join2(cwd, ".reroute", "content.ts");
795
- const reg = await import(pathToFileURL4(registryPath).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
488
+ const registryPath = join(cwd, ".reroute", "content.ts");
489
+ const reg = await import(pathToFileURL4(registryPath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
796
490
  const get = reg?.getContentEntry;
797
491
  const entry = typeof get === "function" ? get(collection, name) : undefined;
798
492
  const moduleUrl = entry?.module;
@@ -802,7 +496,7 @@ async function renderSSRDocument(options) {
802
496
  } catch {}
803
497
  if (!modulePath) {
804
498
  try {
805
- const chunkDir = join2(cwd, ".reroute", "chunks", collection);
499
+ const chunkDir = join(cwd, ".reroute", "chunks", collection);
806
500
  const files = await readdir3(chunkDir);
807
501
  const candidates = files.filter((n) => n.startsWith(`${name}.`) && n.endsWith(".js"));
808
502
  if (candidates.length) {
@@ -810,25 +504,25 @@ async function renderSSRDocument(options) {
810
504
  let latestM = 0;
811
505
  for (const candidateName of candidates) {
812
506
  try {
813
- const s = await stat4(join2(chunkDir, candidateName));
507
+ const s = await stat4(join(chunkDir, candidateName));
814
508
  if (s.mtimeMs >= latestM) {
815
509
  latestM = s.mtimeMs;
816
510
  latest = candidateName;
817
511
  }
818
512
  } catch {}
819
513
  }
820
- modulePath = `/${join2(".reroute", "chunks", collection, latest).replace(/\\+/g, "/")}`;
514
+ modulePath = `/${join(".reroute", "chunks", collection, latest).replace(/\\+/g, "/")}`;
821
515
  }
822
516
  } catch {}
823
517
  }
824
518
  if (!modulePath) {
825
- const tsx = join2(clientDir, "routes", collection, "content", `${name}.tsx`);
826
- const ts = join2(clientDir, "routes", collection, "content", `${name}.ts`);
519
+ const tsx = join(clientDir, "routes", collection, "content", `${name}.tsx`);
520
+ const ts = join(clientDir, "routes", collection, "content", `${name}.ts`);
827
521
  let srcUrl = "";
828
522
  if (await Bun.file(tsx).exists()) {
829
- srcUrl = `/${join2("routes", collection, "content", `${name}.tsx`).replace(/\\+/g, "/")}`;
523
+ srcUrl = `/${join("routes", collection, "content", `${name}.tsx`).replace(/\\+/g, "/")}`;
830
524
  } else if (await Bun.file(ts).exists()) {
831
- srcUrl = `/${join2("routes", collection, "content", `${name}.ts`).replace(/\\+/g, "/")}`;
525
+ srcUrl = `/${join("routes", collection, "content", `${name}.ts`).replace(/\\+/g, "/")}`;
832
526
  }
833
527
  if (srcUrl) {
834
528
  modulePath = srcUrl;
@@ -846,7 +540,7 @@ async function renderSSRDocument(options) {
846
540
  }
847
541
  }
848
542
  } catch {}
849
- await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode2);
543
+ await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode);
850
544
  const __SSR_DATA__ = {};
851
545
  try {
852
546
  try {
@@ -866,15 +560,15 @@ async function renderSSRDocument(options) {
866
560
  }
867
561
  } catch {}
868
562
  try {
869
- const routesPath = join2(cwd, ".reroute", "routes.ts");
870
- const m = await import(pathToFileURL4(routesPath).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
563
+ const routesPath = join(cwd, ".reroute", "routes.ts");
564
+ const m = await import(pathToFileURL4(routesPath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
871
565
  const match = typeof m.matchRoute === "function" ? m.matchRoute(pathname) : null;
872
566
  const r = match?.route;
873
567
  const params = match?.params || {};
874
568
  if (r && typeof r.path === "string") {
875
569
  try {
876
- const abs = join2(clientDir, "routes", String(r.path));
877
- const mod = await import(pathToFileURL4(abs).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
570
+ const abs = join(clientDir, "routes", String(r.path));
571
+ const mod = await import(pathToFileURL4(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
878
572
  const ssr = mod?.ssr;
879
573
  const dataFn = ssr?.data;
880
574
  if (typeof dataFn === "function") {
@@ -890,8 +584,8 @@ async function renderSSRDocument(options) {
890
584
  } catch {}
891
585
  let __byCollectionForSSR = {};
892
586
  try {
893
- const p = join2(cwd, ".reroute", "content.ts");
894
- const mod = await import(pathToFileURL4(p).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
587
+ const p = join(cwd, ".reroute", "content.ts");
588
+ const mod = await import(pathToFileURL4(p).href + (isWatchMode ? `?t=${Date.now()}` : ""));
895
589
  __byCollectionForSSR = mod?.byCollection || {};
896
590
  try {
897
591
  globalThis.__REROUTE_COLLECTIONS__ = __byCollectionForSSR;
@@ -905,10 +599,10 @@ async function renderSSRDocument(options) {
905
599
  let inlineStyleTag = "";
906
600
  try {
907
601
  const candidates = [
908
- join2(clientDir, "..", ".reroute", "theme.css"),
909
- join2(clientDir, "..", "..", ".reroute", "theme.css"),
910
- join2(clientDir, "..", "..", "..", ".reroute", "theme.css"),
911
- join2(clientDir, "..", "..", "..", "..", ".reroute", "theme.css")
602
+ join(clientDir, "..", ".reroute", "theme.css"),
603
+ join(clientDir, "..", "..", ".reroute", "theme.css"),
604
+ join(clientDir, "..", "..", "..", ".reroute", "theme.css"),
605
+ join(clientDir, "..", "..", "..", "..", ".reroute", "theme.css")
912
606
  ];
913
607
  let cssPath = "";
914
608
  for (const p of candidates) {
@@ -991,7 +685,7 @@ async function renderSSRDocument(options) {
991
685
  </script>`;
992
686
  } catch {}
993
687
  hydrationScript += scripts.map((src) => `<script type="module" src="${src}"></script>`).join("");
994
- if (isWatchMode2) {
688
+ if (isWatchMode) {
995
689
  hydrationScript += `<script type="module" src="/__reroute_watch.js"></script>`;
996
690
  }
997
691
  let perPageHead = "";
@@ -1016,8 +710,8 @@ ${ssrHead}`;
1016
710
  }
1017
711
  } catch {}
1018
712
  try {
1019
- const routesPath = join2(cwd, ".reroute", "routes.ts");
1020
- const m = await import(pathToFileURL4(routesPath).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
713
+ const routesPath = join(cwd, ".reroute", "routes.ts");
714
+ const m = await import(pathToFileURL4(routesPath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
1021
715
  const match = typeof m.matchRoute === "function" ? m.matchRoute(pathname) : null;
1022
716
  const r = match?.route;
1023
717
  if (!r) {
@@ -1025,8 +719,8 @@ ${ssrHead}`;
1025
719
  }
1026
720
  if (r && typeof r.path === "string") {
1027
721
  try {
1028
- const abs = join2(clientDir, "routes", String(r.path));
1029
- const mod = await import(pathToFileURL4(abs).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
722
+ const abs = join(clientDir, "routes", String(r.path));
723
+ const mod = await import(pathToFileURL4(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
1030
724
  const meta = mod?.meta;
1031
725
  const ssr = mod?.ssr;
1032
726
  if (meta)
@@ -1060,8 +754,8 @@ ${ssrHead}`;
1060
754
  }
1061
755
  if (chosen && typeof chosen.path === "string") {
1062
756
  try {
1063
- const abs = join2(clientDir, "routes", String(chosen.path));
1064
- const mod = await import(pathToFileURL4(abs).href + (isWatchMode2 ? `?t=${Date.now()}` : ""));
757
+ const abs = join(clientDir, "routes", String(chosen.path));
758
+ const mod = await import(pathToFileURL4(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
1065
759
  const meta = mod?.meta;
1066
760
  const ssr = mod?.ssr;
1067
761
  if (meta)
@@ -1195,7 +889,6 @@ function gzipIfAccepted(body, contentType, acceptEncoding) {
1195
889
  return { body, extraHeaders };
1196
890
  }
1197
891
  export {
1198
- transpileFile,
1199
892
  toBytes,
1200
893
  stripStart,
1201
894
  stripEnd,
@@ -1203,20 +896,16 @@ export {
1203
896
  renderSSRDocument,
1204
897
  loadIndexHtml,
1205
898
  listContentFiles,
1206
- join2 as join,
899
+ join,
1207
900
  isCompressible,
1208
901
  gzipIfAccepted,
1209
- getStaticDepsForUrl,
1210
902
  getMimeType,
1211
903
  getContentMeta,
1212
- getBundleUrlsFor,
1213
- generateContentRegistry,
1214
904
  generateContentHash,
1215
905
  extname,
1216
906
  discoverCollections,
1217
907
  computeSSRDataForPath,
1218
908
  buildHeadFromMeta,
1219
- buildContentDTOs,
1220
909
  basename,
1221
910
  applyIndexTemplate,
1222
911
  acceptsGzip,
@@ -1224,4 +913,4 @@ export {
1224
913
  LRUCache
1225
914
  };
1226
915
 
1227
- //# debugId=323E949623A6CDDC64756E2164756E21
916
+ //# debugId=2ECB77FDAD13338864756E2164756E21