reroute-js 1.0.0-alpha.0 → 1.0.0-alpha.2

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 (199) hide show
  1. package/README.md +1 -1
  2. package/cli/bin.d.ts +1 -1
  3. package/cli/bin.js +136 -67
  4. package/cli/bin.js.map +6 -6
  5. package/cli/index.d.ts +1 -1
  6. package/cli/index.js +66 -13
  7. package/cli/index.js.map +3 -3
  8. package/cli/src/cli.d.ts +1 -1
  9. package/cli/src/commands/analyze.d.ts +1 -1
  10. package/cli/src/commands/build.d.ts +1 -1
  11. package/cli/src/commands/dev.d.ts +1 -1
  12. package/cli/src/commands/gen.d.ts +1 -1
  13. package/cli/src/commands/gen.d.ts.map +1 -1
  14. package/cli/src/commands/index.d.ts +1 -1
  15. package/cli/src/commands/init.d.ts +1 -1
  16. package/cli/src/commands/lib/assets.d.ts +1 -1
  17. package/cli/src/commands/lib/bundler.d.ts +1 -1
  18. package/cli/src/commands/lib/command.d.ts +1 -1
  19. package/cli/src/commands/lib/env.d.ts +1 -1
  20. package/cli/src/commands/lib/index.d.ts +1 -1
  21. package/cli/src/commands/lib/log.d.ts +1 -1
  22. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  24. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  25. package/cli/src/commands/lib/production.d.ts +1 -1
  26. package/cli/src/commands/lib/server.d.ts +1 -1
  27. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  28. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  29. package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
  30. package/cli/src/commands/lib/theme.d.ts +18 -4
  31. package/cli/src/commands/lib/theme.d.ts.map +1 -1
  32. package/cli/src/commands/lib/version.d.ts +1 -1
  33. package/cli/src/commands/og.d.ts +1 -1
  34. package/cli/src/commands/start.d.ts +1 -1
  35. package/cli/src/index.d.ts +1 -1
  36. package/core/index.d.ts +1 -1
  37. package/core/index.js +7 -7
  38. package/core/index.js.map +2 -2
  39. package/core/src/bundler/hash.d.ts +1 -1
  40. package/core/src/bundler/index.d.ts +1 -1
  41. package/core/src/config.d.ts +1 -1
  42. package/core/src/content/discovery.d.ts +1 -1
  43. package/core/src/content/index.d.ts +1 -1
  44. package/core/src/content/metadata.d.ts +1 -1
  45. package/core/src/i18n/catalog.d.ts +1 -1
  46. package/core/src/i18n/discover.d.ts +1 -1
  47. package/core/src/i18n/index.d.ts +1 -1
  48. package/core/src/i18n/messages.d.ts +1 -1
  49. package/core/src/i18n/negotiate.d.ts +1 -1
  50. package/core/src/i18n/pathname.d.ts +1 -1
  51. package/core/src/i18n/resolve.d.ts +1 -1
  52. package/core/src/i18n/types.d.ts +1 -1
  53. package/core/src/index.d.ts +1 -1
  54. package/core/src/llms/extractor.d.ts +1 -1
  55. package/core/src/llms/formatter.d.ts +1 -1
  56. package/core/src/llms/full-generator.d.ts +1 -1
  57. package/core/src/llms/index-generator.d.ts +1 -1
  58. package/core/src/llms/index.d.ts +1 -1
  59. package/core/src/og/discovery.d.ts +1 -1
  60. package/core/src/og/index.d.ts +1 -1
  61. package/core/src/og/meta.d.ts +1 -1
  62. package/core/src/og/render.d.ts +1 -1
  63. package/core/src/og/types.d.ts +1 -1
  64. package/core/src/robots/discovery.d.ts +1 -1
  65. package/core/src/robots/generator.d.ts +1 -1
  66. package/core/src/robots/index.d.ts +1 -1
  67. package/core/src/robots/policies.d.ts +1 -1
  68. package/core/src/rss/discovery.d.ts +1 -1
  69. package/core/src/rss/generator.d.ts +1 -1
  70. package/core/src/rss/index.d.ts +1 -1
  71. package/core/src/sitemap/discovery.d.ts +1 -1
  72. package/core/src/sitemap/generator.d.ts +1 -1
  73. package/core/src/sitemap/index.d.ts +1 -1
  74. package/core/src/ssr/index.d.ts +1 -1
  75. package/core/src/ssr/lib/cache.d.ts +1 -1
  76. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  77. package/core/src/ssr/lib/collections.d.ts +1 -1
  78. package/core/src/ssr/lib/compression.d.ts +1 -1
  79. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  80. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  81. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  82. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  83. package/core/src/ssr/lib/content-path.d.ts +1 -1
  84. package/core/src/ssr/lib/data.d.ts +1 -1
  85. package/core/src/ssr/lib/html.d.ts +1 -1
  86. package/core/src/ssr/lib/imports.d.ts +1 -1
  87. package/core/src/ssr/lib/index.d.ts +1 -1
  88. package/core/src/ssr/lib/layouts.d.ts +1 -1
  89. package/core/src/ssr/lib/metadata.d.ts +1 -1
  90. package/core/src/ssr/lib/mime.d.ts +1 -1
  91. package/core/src/ssr/lib/modules.d.ts +1 -1
  92. package/core/src/ssr/lib/path.d.ts +1 -1
  93. package/core/src/ssr/lib/preload.d.ts +1 -1
  94. package/core/src/ssr/lib/route-match.d.ts +1 -1
  95. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  96. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  97. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  98. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  99. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  100. package/core/src/ssr/lib/seed.d.ts +1 -1
  101. package/core/src/ssr/lib/serialize.d.ts +1 -1
  102. package/core/src/ssr/lib/setup.d.ts +1 -1
  103. package/core/src/ssr/lib/styles.d.ts +1 -1
  104. package/core/src/ssr/lib/template.d.ts +1 -1
  105. package/core/src/ssr/lib/types.d.ts +1 -1
  106. package/core/src/ssr/render.d.ts +1 -1
  107. package/core/src/ssr/stream.d.ts +1 -1
  108. package/elysia/index.d.ts +1 -1
  109. package/elysia/index.js +102 -26
  110. package/elysia/index.js.map +6 -6
  111. package/elysia/src/index.d.ts +1 -1
  112. package/elysia/src/libs/assets.d.ts +1 -1
  113. package/elysia/src/libs/cache.d.ts +1 -1
  114. package/elysia/src/libs/caching.d.ts +1 -1
  115. package/elysia/src/libs/http.d.ts +1 -1
  116. package/elysia/src/libs/i18n.d.ts +1 -1
  117. package/elysia/src/libs/image.d.ts +1 -1
  118. package/elysia/src/libs/index.d.ts +1 -1
  119. package/elysia/src/libs/llms.d.ts +1 -1
  120. package/elysia/src/libs/response.d.ts +1 -1
  121. package/elysia/src/libs/serving.d.ts +1 -1
  122. package/elysia/src/plugin.d.ts +1 -1
  123. package/elysia/src/plugin.d.ts.map +1 -1
  124. package/elysia/src/routes/artifacts.d.ts +1 -1
  125. package/elysia/src/routes/content.d.ts +1 -1
  126. package/elysia/src/routes/image.d.ts +1 -1
  127. package/elysia/src/routes/index.d.ts +1 -1
  128. package/elysia/src/routes/internal.d.ts +3 -2
  129. package/elysia/src/routes/internal.d.ts.map +1 -1
  130. package/elysia/src/routes/llms.d.ts +1 -1
  131. package/elysia/src/routes/og.d.ts +1 -1
  132. package/elysia/src/routes/redirects.d.ts +1 -1
  133. package/elysia/src/routes/robots.d.ts +1 -1
  134. package/elysia/src/routes/rss.d.ts +1 -1
  135. package/elysia/src/routes/search.d.ts +1 -1
  136. package/elysia/src/routes/sitemap.d.ts +1 -1
  137. package/elysia/src/routes/ssr.d.ts +1 -1
  138. package/elysia/src/routes/static.d.ts +1 -1
  139. package/elysia/src/types.d.ts +1 -1
  140. package/package.json +1 -1
  141. package/react/index.d.ts +1 -1
  142. package/react/index.js +2 -2
  143. package/react/index.js.map +1 -1
  144. package/react/src/components/ClientOnly.d.ts +1 -1
  145. package/react/src/components/ContentRoute.d.ts +1 -1
  146. package/react/src/components/Image.d.ts +1 -1
  147. package/react/src/components/LazyRoute.d.ts +1 -1
  148. package/react/src/components/Link.d.ts +1 -1
  149. package/react/src/components/Markdown.d.ts +1 -1
  150. package/react/src/components/Outlet.d.ts +1 -1
  151. package/react/src/components/index.d.ts +1 -1
  152. package/react/src/hooks/index.d.ts +1 -1
  153. package/react/src/hooks/useContent.d.ts +1 -1
  154. package/react/src/hooks/useData.d.ts +1 -1
  155. package/react/src/hooks/useFeed.d.ts +1 -1
  156. package/react/src/hooks/useLayoutData.d.ts +1 -1
  157. package/react/src/hooks/useLlms.d.ts +1 -1
  158. package/react/src/hooks/useNavigate.d.ts +1 -1
  159. package/react/src/hooks/useParams.d.ts +1 -1
  160. package/react/src/hooks/useRouter.d.ts +1 -1
  161. package/react/src/hooks/useSearch.d.ts +1 -1
  162. package/react/src/hooks/useSearchParams.d.ts +1 -1
  163. package/react/src/hooks/useToc.d.ts +1 -1
  164. package/react/src/i18n/LocaleProvider.d.ts +1 -1
  165. package/react/src/i18n/helpers.d.ts +1 -1
  166. package/react/src/i18n/index.d.ts +1 -1
  167. package/react/src/index.d.ts +1 -1
  168. package/react/src/lib/collection.d.ts +1 -1
  169. package/react/src/lib/content.d.ts +1 -1
  170. package/react/src/lib/head.d.ts +1 -1
  171. package/react/src/lib/index.d.ts +1 -1
  172. package/react/src/lib/lazy-route.d.ts +1 -1
  173. package/react/src/lib/route-loader.d.ts +1 -1
  174. package/react/src/providers/ContentProvider.d.ts +1 -1
  175. package/react/src/providers/RerouteProvider.d.ts +1 -1
  176. package/react/src/providers/RouterProvider.d.ts +1 -1
  177. package/react/src/providers/index.d.ts +1 -1
  178. package/react/src/types/any.d.ts +1 -1
  179. package/react/src/types/index.d.ts +1 -1
  180. package/react/src/types/router.d.ts +1 -1
  181. package/telemetry/react.d.ts +1 -1
  182. package/telemetry/react.js +2 -2
  183. package/telemetry/react.js.map +1 -1
  184. package/telemetry/server.d.ts +1 -1
  185. package/telemetry/server.js +2 -2
  186. package/telemetry/server.js.map +1 -1
  187. package/telemetry/src/react/api.d.ts +1 -1
  188. package/telemetry/src/react/context.d.ts +1 -1
  189. package/telemetry/src/react/index.d.ts +1 -1
  190. package/telemetry/src/react/telemetry.d.ts +1 -1
  191. package/telemetry/src/server/context.d.ts +1 -1
  192. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  193. package/telemetry/src/server/headers/index.d.ts +1 -1
  194. package/telemetry/src/server/headers/presets.d.ts +1 -1
  195. package/telemetry/src/server/index.d.ts +1 -1
  196. package/telemetry/src/server/instrumentation.d.ts +1 -1
  197. package/telemetry/src/server/plugin.d.ts +1 -1
  198. package/telemetry/src/server/sourcemap.d.ts +1 -1
  199. /package/_/store/src/client/{theme.css → index.css} +0 -0
package/README.md CHANGED
@@ -179,7 +179,7 @@ Reroute is a feature-rich file-based routing framework for building fullstack Re
179
179
  - ⚡ **React 19 Streaming** - Native `renderToReadableStream` for optimal performance
180
180
 
181
181
  ### 🎨 Styling & Theming
182
- - 🎨 **Native CSS** - Author styles in `src/client/theme.css` with no CSS framework required
182
+ - 🎨 **Native CSS** - Author styles in `src/client/index.css` with no CSS framework required
183
183
  - ⚡ **Live CSS Reload** - Instant style updates in development mode
184
184
  - 🔧 **Zero Config** - Theme CSS is synced automatically during `reroute gen`
185
185
 
package/cli/bin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v1.0.0-alpha.0
2
+ * reroute-js v1.0.0-alpha.2
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2026 stewones <hi@stewan.io>
package/cli/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  /**
4
- * reroute-js v1.0.0-alpha.0
4
+ * reroute-js v1.0.0-alpha.2
5
5
  *
6
6
  * @license MIT
7
7
  * @copyright 2026 stewones <hi@stewan.io>
@@ -66,7 +66,7 @@ async function getVersionString() {
66
66
  }
67
67
  async function getVersion() {
68
68
  if (true) {
69
- return "1.0.0-alpha.0";
69
+ return "1.0.0-alpha.2";
70
70
  }
71
71
  const possiblePaths = [
72
72
  path.join(import.meta.dir, "../../../../package.json"),
@@ -84,7 +84,7 @@ async function getVersion() {
84
84
  }
85
85
  async function getCommit() {
86
86
  if (true) {
87
- return "9abafce";
87
+ return "3e34125";
88
88
  }
89
89
  return "dev";
90
90
  }
@@ -325,7 +325,7 @@ function printSuccess(projectName, template) {
325
325
  console.log(" | |-- products/");
326
326
  console.log(" | |-- categories/");
327
327
  console.log(" |-- lib/ # API client & utilities");
328
- console.log(" +-- theme.css # Theme CSS");
328
+ console.log(" +-- index.css # Client CSS");
329
329
  }
330
330
  console.log(" | |-- index.tsx");
331
331
  console.log(" | +-- about.tsx");
@@ -3733,13 +3733,13 @@ async function inlineThemeCSS(clientDir, minify = false, isWatchMode = false) {
3733
3733
  }
3734
3734
  if (isWatchMode) {
3735
3735
  const timestamp = Date.now();
3736
- return `<link rel="stylesheet" href="/.reroute/theme.css?t=${timestamp}" data-reroute="theme">`;
3736
+ return `<link rel="stylesheet" href="/.reroute/index.css?t=${timestamp}" data-reroute="theme">`;
3737
3737
  }
3738
3738
  const candidates = [
3739
- join2(clientDir, "..", ".reroute", "theme.css"),
3740
- join2(clientDir, "..", "..", ".reroute", "theme.css"),
3741
- join2(clientDir, "..", "..", "..", ".reroute", "theme.css"),
3742
- join2(clientDir, "..", "..", "..", "..", ".reroute", "theme.css")
3739
+ join2(clientDir, "..", ".reroute", "index.css"),
3740
+ join2(clientDir, "..", "..", ".reroute", "index.css"),
3741
+ join2(clientDir, "..", "..", "..", ".reroute", "index.css"),
3742
+ join2(clientDir, "..", "..", "..", "..", ".reroute", "index.css")
3743
3743
  ];
3744
3744
  let cssPath = "";
3745
3745
  for (const p of candidates) {
@@ -7376,25 +7376,79 @@ var AUTO_HEADER = `// \uD83D\uDEA8 Auto-generated streaming wrapper by Reroute -
7376
7376
  var init_suspense = () => {};
7377
7377
 
7378
7378
  // packages/cli/src/commands/lib/theme.ts
7379
- import { existsSync as existsSync5 } from "node:fs";
7380
- import { mkdir as mkdir2 } from "node:fs/promises";
7381
- import { dirname as dirname5, join as join9 } from "node:path";
7382
- function getThemePaths(cwd) {
7383
- const input = join9(cwd, "src/client/theme.css");
7384
- const output = join9(cwd, ".reroute/theme.css");
7379
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
7380
+ import { mkdir as mkdir2, writeFile } from "node:fs/promises";
7381
+ import { dirname as dirname5, isAbsolute, join as join9, resolve as resolve2 } from "node:path";
7382
+ function getCssPaths(cwd) {
7383
+ const input = join9(cwd, "src/client/index.css");
7384
+ const output = join9(cwd, ".reroute/index.css");
7385
7385
  return { input, output };
7386
7386
  }
7387
+ function isFileImport(specifier) {
7388
+ if (specifier.startsWith("http://") || specifier.startsWith("https://") || specifier.startsWith("data:") || specifier.startsWith("/")) {
7389
+ return false;
7390
+ }
7391
+ return true;
7392
+ }
7393
+ function bundleCssEntrypoint(entryPath) {
7394
+ const absEntry = resolve2(entryPath);
7395
+ const stack = new Set;
7396
+ const completed = new Set;
7397
+ function bundleFile(filePath) {
7398
+ const absPath = resolve2(filePath);
7399
+ if (completed.has(absPath)) {
7400
+ return "";
7401
+ }
7402
+ if (stack.has(absPath)) {
7403
+ throw new Error(`[reroute/theme] Circular @import detected: ${absPath}`);
7404
+ }
7405
+ if (!existsSync5(absPath)) {
7406
+ throw new Error(`[reroute/theme] Missing CSS import: ${absPath}`);
7407
+ }
7408
+ stack.add(absPath);
7409
+ const source = readFileSync4(absPath, "utf-8");
7410
+ const baseDir = dirname5(absPath);
7411
+ const bundled = source.replace(IMPORT_RE, (full, single, double, bare, rest) => {
7412
+ const specifier = single || double || bare;
7413
+ const condition = (rest ?? "").trim();
7414
+ if (condition || !isFileImport(specifier)) {
7415
+ return full;
7416
+ }
7417
+ const importedPath = isAbsolute(specifier) ? specifier : resolve2(baseDir, specifier);
7418
+ return `/* ${specifier} */
7419
+ ${bundleFile(importedPath)}
7420
+ `;
7421
+ });
7422
+ stack.delete(absPath);
7423
+ completed.add(absPath);
7424
+ return bundled;
7425
+ }
7426
+ return bundleFile(absEntry);
7427
+ }
7387
7428
  async function syncThemeCss(cwd) {
7388
- const { input, output } = getThemePaths(cwd);
7429
+ const { input, output } = getCssPaths(cwd);
7389
7430
  if (!existsSync5(input)) {
7390
7431
  return false;
7391
7432
  }
7392
7433
  await mkdir2(dirname5(output), { recursive: true });
7393
- await Bun.write(output, Bun.file(input));
7394
- console.log("[reroute/theme] synced theme.css");
7434
+ try {
7435
+ const css = bundleCssEntrypoint(input);
7436
+ await writeFile(output, css, "utf-8");
7437
+ } catch (err) {
7438
+ const message = err instanceof Error ? err.message : String(err);
7439
+ if (message.startsWith("[reroute/theme]")) {
7440
+ throw err;
7441
+ }
7442
+ throw new Error(`[reroute/theme] Failed to bundle index.css:
7443
+ ${message}`);
7444
+ }
7445
+ console.log("[reroute/theme] synced index.css");
7395
7446
  return true;
7396
7447
  }
7397
- var init_theme = () => {};
7448
+ var IMPORT_RE;
7449
+ var init_theme = __esm(() => {
7450
+ IMPORT_RE = /@import\s+(?:url\(\s*)?(?:'([^']+)'|"([^"]+)"|([^'")\s]+))\s*\)?\s*([^;]*);/g;
7451
+ });
7398
7452
 
7399
7453
  // packages/cli/src/commands/gen.ts
7400
7454
  var exports_gen = {};
@@ -7406,10 +7460,10 @@ import { mkdir as mkdir3, readdir as readdir7, rm } from "node:fs/promises";
7406
7460
  import { dirname as dirname6, join as join10 } from "node:path";
7407
7461
  import { pathToFileURL as pathToFileURL8 } from "node:url";
7408
7462
  async function bundleThemeCssIntoArtifacts(cwd) {
7409
- const themeCssPath = join10(cwd, ".reroute", "theme.css");
7463
+ const cssPath = join10(cwd, ".reroute", "index.css");
7410
7464
  const artifactsPath = join10(cwd, OUTPUT_ARTIFACTS);
7411
7465
  try {
7412
- const cssContent = await Bun.file(themeCssPath).text();
7466
+ const cssContent = await Bun.file(cssPath).text();
7413
7467
  if (!cssContent)
7414
7468
  return;
7415
7469
  let artifactsContent = await Bun.file(artifactsPath).text();
@@ -7417,7 +7471,7 @@ async function bundleThemeCssIntoArtifacts(cwd) {
7417
7471
  return;
7418
7472
  }
7419
7473
  const cssLine = `
7420
- // Bundled theme.css for compiled binary support
7474
+ // Bundled index.css for compiled binary support
7421
7475
  (globalThis as any).__REROUTE_THEME_CSS__ = ${JSON.stringify(cssContent)};
7422
7476
  `;
7423
7477
  const exportIndex = artifactsContent.lastIndexOf("export type RerouteBundle");
@@ -8759,14 +8813,16 @@ async function gen(args) {
8759
8813
  console.log(`[reroute/gen] rebuilding notified (port ${port}, ${data.clients} browser(s))`);
8760
8814
  } catch (_err) {}
8761
8815
  };
8762
- const notifyReload = async (reason) => {
8816
+ const notifyReload = async (reason, mode = "full") => {
8763
8817
  const port = getPort();
8764
8818
  try {
8765
8819
  const response = await fetch(`http://localhost:${port}/__reroute_reload`, {
8766
- method: "POST"
8820
+ method: "POST",
8821
+ headers: { "content-type": "application/json" },
8822
+ body: JSON.stringify({ mode })
8767
8823
  });
8768
8824
  const data = await response.json();
8769
- console.log(`[reroute/gen] reload notified (port ${port}, ${data.clients} browser(s))${reason ? `: ${reason}` : ""}`);
8825
+ console.log(`[reroute/gen] reload notified (port ${port}, ${data.clients} browser(s), ${mode})${reason ? `: ${reason}` : ""}`);
8770
8826
  } catch {}
8771
8827
  };
8772
8828
  await notifyReload("initial generation");
@@ -8775,30 +8831,35 @@ async function gen(args) {
8775
8831
  let isBuilding = false;
8776
8832
  let pendingBuild = null;
8777
8833
  let skipCurrentBuild = false;
8778
- function scheduleBuild(buildFn, reason) {
8834
+ function scheduleBuild(buildFn, reason, reloadMode = "full") {
8779
8835
  if (isBuilding) {
8780
8836
  if (!skipCurrentBuild) {
8781
8837
  skipCurrentBuild = true;
8782
8838
  console.log(`[reroute/watch] ⏭️ Superseding current build with: ${reason}`);
8783
8839
  }
8784
- pendingBuild = { fn: buildFn, reason };
8840
+ pendingBuild = { fn: buildFn, reason, reloadMode };
8785
8841
  return;
8786
8842
  }
8787
8843
  if (pendingBuild) {
8788
8844
  console.log(`[reroute/watch] ⏭️ Replacing queued build with: ${reason}`);
8845
+ const mergedMode = pendingBuild.reloadMode === "css" && reloadMode === "css" ? "css" : "full";
8846
+ pendingBuild = { fn: buildFn, reason, reloadMode: mergedMode };
8847
+ } else {
8848
+ pendingBuild = { fn: buildFn, reason, reloadMode };
8789
8849
  }
8790
- pendingBuild = { fn: buildFn, reason };
8791
8850
  processPendingBuild();
8792
8851
  }
8793
8852
  async function processPendingBuild() {
8794
8853
  if (!pendingBuild || isBuilding)
8795
8854
  return;
8796
- const { fn: buildFn, reason } = pendingBuild;
8855
+ const { fn: buildFn, reason, reloadMode } = pendingBuild;
8797
8856
  pendingBuild = null;
8798
8857
  skipCurrentBuild = false;
8799
8858
  isBuilding = true;
8800
8859
  const startTime = performance.now();
8801
- await notifyRebuilding();
8860
+ if (reloadMode !== "css") {
8861
+ await notifyRebuilding();
8862
+ }
8802
8863
  try {
8803
8864
  await buildFn();
8804
8865
  if (skipCurrentBuild) {
@@ -8807,12 +8868,14 @@ async function gen(args) {
8807
8868
  }
8808
8869
  const duration = ((performance.now() - startTime) / 1000).toFixed(2);
8809
8870
  console.log(`[reroute/watch] ✓ Rebuild complete in ${duration}s (${reason})`);
8810
- await Bun.sleep(200);
8871
+ if (reloadMode !== "css") {
8872
+ await Bun.sleep(200);
8873
+ }
8811
8874
  if (skipCurrentBuild || pendingBuild) {
8812
8875
  console.log(`[reroute/watch] ⏭️ Skipping reload, new build pending`);
8813
8876
  return;
8814
8877
  }
8815
- await notifyReload(reason);
8878
+ await notifyReload(reason, reloadMode);
8816
8879
  } catch (err) {
8817
8880
  if (!skipCurrentBuild) {
8818
8881
  console.error(`[reroute/watch] ✗ Build failed (${reason}):`, err);
@@ -8963,13 +9026,14 @@ async function gen(args) {
8963
9026
  }
8964
9027
  const themeSynced = await syncThemeCss(cwd);
8965
9028
  if (themeSynced) {
8966
- console.log("[reroute/watch] ├─ Theme CSS synced");
9029
+ console.log("[reroute/watch] ├─ index.css synced");
8967
9030
  }
8968
9031
  }, "routes change");
8969
9032
  });
8970
9033
  });
8971
9034
  const clientPath = join10(cwd, "src", "client");
8972
9035
  console.log(`[reroute/watch] \uD83D\uDCE6 Watching ${clientPath}...`);
9036
+ let pendingClientFiles = new Set;
8973
9037
  const clientWatcher = watch(clientPath, { recursive: true }, (_ev, filename) => {
8974
9038
  if (!filename)
8975
9039
  return;
@@ -8980,10 +9044,15 @@ async function gen(args) {
8980
9044
  return;
8981
9045
  if (!/\.(tsx|ts|jsx|js|html|md|mdx|css)$/.test(name))
8982
9046
  return;
9047
+ pendingClientFiles.add(name);
8983
9048
  mediumDebounce(() => {
9049
+ const names = [...pendingClientFiles];
9050
+ pendingClientFiles = new Set;
9051
+ const reloadMode = names.every((n) => n.endsWith(".css")) ? "css" : "full";
9052
+ const label = names.length === 1 ? names[0] : `${names.length} files`;
8984
9053
  scheduleBuild(async () => {
8985
- console.log(`[reroute/watch] \uD83D\uDCE6 Client changed: ${name}`);
8986
- if (name.endsWith(".ts") || name.endsWith(".tsx")) {
9054
+ console.log(`[reroute/watch] \uD83D\uDCE6 Client changed: ${label}`);
9055
+ if (names.some((n) => n.endsWith(".ts") || n.endsWith(".tsx"))) {
8987
9056
  console.log("[reroute/watch] ├─ Rebuilding bundle...");
8988
9057
  const bundleStart = performance.now();
8989
9058
  try {
@@ -8997,9 +9066,9 @@ async function gen(args) {
8997
9066
  }
8998
9067
  const themeSynced = await syncThemeCss(cwd);
8999
9068
  if (themeSynced) {
9000
- console.log("[reroute/watch] ├─ Theme CSS synced");
9069
+ console.log("[reroute/watch] ├─ index.css synced");
9001
9070
  }
9002
- }, "client change");
9071
+ }, "client change", reloadMode);
9003
9072
  });
9004
9073
  });
9005
9074
  console.log(`[reroute/watch] ✓ Watch mode active - ready for changes!
@@ -9096,7 +9165,7 @@ async function waitForServerReady(port = 3000, timeout = 30000) {
9096
9165
  return;
9097
9166
  }
9098
9167
  } catch {}
9099
- await new Promise((resolve2) => setTimeout(resolve2, checkInterval));
9168
+ await new Promise((resolve3) => setTimeout(resolve3, checkInterval));
9100
9169
  checkInterval = Math.min(checkInterval * 1.5, maxInterval);
9101
9170
  }
9102
9171
  throw new Error(`Timeout waiting for server to respond after ${timeout}ms. ` + `Make sure your server is starting correctly on port ${port}.`);
@@ -19437,12 +19506,12 @@ var require_screen = __commonJS((exports, module) => {
19437
19506
  env: process.env,
19438
19507
  cwd: process.env.HOME
19439
19508
  };
19440
- function writeFile(callback2) {
19509
+ function writeFile2(callback2) {
19441
19510
  if (!options.value)
19442
19511
  return callback2();
19443
19512
  return fs.writeFile(file, options.value, callback2);
19444
19513
  }
19445
- return writeFile(function(err) {
19514
+ return writeFile2(function(err) {
19446
19515
  if (err)
19447
19516
  return callback(err);
19448
19517
  return self2.exec(editor, args, opt, function(err2, success) {
@@ -94793,7 +94862,7 @@ Should be of format "before:after"`);
94793
94862
  }
94794
94863
  }
94795
94864
  function objectize(node) {
94796
- function resolve2(value, key) {
94865
+ function resolve3(value, key) {
94797
94866
  if (!value._parent)
94798
94867
  return;
94799
94868
  if (value._parent._default && value._parent._default[key])
@@ -94816,8 +94885,8 @@ Should be of format "before:after"`);
94816
94885
  if (isObject(value)) {
94817
94886
  if (!value._before && !value._after)
94818
94887
  return objectize(value);
94819
- value._before = value._before || resolve2(value, "_before");
94820
- value._after = value._after || resolve2(value, "_after");
94888
+ value._before = value._before || resolve3(value, "_before");
94889
+ value._after = value._after || resolve3(value, "_after");
94821
94890
  return;
94822
94891
  }
94823
94892
  throw new Error("nodes need to be either {String}, {Object} or {Function}." + value + " is neither.");
@@ -103726,7 +103795,7 @@ function getRerouteCommand() {
103726
103795
  async function waitForInitialBuild(genProcess) {
103727
103796
  console.log("[reroute/dev] Waiting for initial build...");
103728
103797
  const outputBuffer = [];
103729
- const buildCompletePromise = new Promise((resolve2, reject) => {
103798
+ const buildCompletePromise = new Promise((resolve3, reject) => {
103730
103799
  const timeout = setTimeout(() => {
103731
103800
  reject(new Error("Timeout waiting for initial build to complete (120s)"));
103732
103801
  }, 120000);
@@ -103736,7 +103805,7 @@ async function waitForInitialBuild(genProcess) {
103736
103805
  clearTimeout(timeout);
103737
103806
  genProcess.stdout?.removeListener("data", checkComplete);
103738
103807
  genProcess.stderr?.removeListener("data", checkComplete);
103739
- resolve2();
103808
+ resolve3();
103740
103809
  }
103741
103810
  };
103742
103811
  genProcess.stdout?.on("data", checkComplete);
@@ -103922,7 +103991,7 @@ async function start(args) {
103922
103991
  `);
103923
103992
  const genCommand = useShell ? `${rerouteCmd} gen ${genArgs.join(" ")}` : rerouteCmd;
103924
103993
  const genArgsWithCmd = useShell ? [] : ["gen", ...genArgs];
103925
- await new Promise((resolve2, reject) => {
103994
+ await new Promise((resolve3, reject) => {
103926
103995
  const genProcess = spawn2(genCommand, genArgsWithCmd, {
103927
103996
  stdio: ["ignore", "pipe", "pipe"],
103928
103997
  shell: useShell
@@ -103933,7 +104002,7 @@ async function start(args) {
103933
104002
  if (code !== null && code !== 0) {
103934
104003
  reject(new Error(`Gen exited with code ${code}`));
103935
104004
  } else {
103936
- resolve2();
104005
+ resolve3();
103937
104006
  }
103938
104007
  });
103939
104008
  genProcess.on("error", (error) => {
@@ -103974,13 +104043,13 @@ async function start(args) {
103974
104043
  serverProcess.kill("SIGINT");
103975
104044
  process.exit(0);
103976
104045
  });
103977
- await new Promise((resolve2, reject) => {
104046
+ await new Promise((resolve3, reject) => {
103978
104047
  serverProcess.on("exit", (code) => {
103979
104048
  if (code !== null && code !== 0) {
103980
104049
  console.error(colorizeLogPrefixAnsi(`[reroute/start] Server exited with code ${code}`));
103981
104050
  reject(new Error(`Server exited with code ${code}`));
103982
104051
  } else {
103983
- resolve2();
104052
+ resolve3();
103984
104053
  }
103985
104054
  });
103986
104055
  serverProcess.on("error", (error) => {
@@ -104042,7 +104111,7 @@ __export(exports_build, {
104042
104111
  default: () => build
104043
104112
  });
104044
104113
  import { spawn as spawn3 } from "node:child_process";
104045
- import { existsSync as existsSync9, readFileSync as readFileSync4, rmSync, unlinkSync } from "node:fs";
104114
+ import { existsSync as existsSync9, readFileSync as readFileSync5, rmSync, unlinkSync } from "node:fs";
104046
104115
  import { join as join14 } from "node:path";
104047
104116
  function getRerouteCommand3() {
104048
104117
  const binPath = join14(import.meta.dir, "..", "..", "bin.ts");
@@ -104069,7 +104138,7 @@ function getOutputName() {
104069
104138
  const packageJsonPath = join14(cwd, "package.json");
104070
104139
  if (existsSync9(packageJsonPath)) {
104071
104140
  try {
104072
- const packageJson = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
104141
+ const packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
104073
104142
  const name = packageJson.name;
104074
104143
  if (name) {
104075
104144
  const parts = name.split("-");
@@ -104111,7 +104180,7 @@ async function cleanRerouteFolder(cwd) {
104111
104180
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Cleaning .reroute folder...
104112
104181
  `));
104113
104182
  rmSync(rerouteDir, { recursive: true, force: true });
104114
- await new Promise((resolve2) => setTimeout(resolve2, 100));
104183
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
104115
104184
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] ✓ .reroute folder cleaned
104116
104185
  `));
104117
104186
  }
@@ -104137,7 +104206,7 @@ async function runGenCommand(rerouteCmd, useShell, noCompression) {
104137
104206
  const genArgs = useShell ? [] : ["gen", "--prod", noCompression ? "--no-compression" : ""];
104138
104207
  const genBuffer = { current: "" };
104139
104208
  const handleGenOutput = createOutputHandler(genBuffer);
104140
- await new Promise((resolve2, reject) => {
104209
+ await new Promise((resolve3, reject) => {
104141
104210
  const genProcess = spawn3(genCommand, genArgs, {
104142
104211
  stdio: ["ignore", "pipe", "pipe"],
104143
104212
  shell: useShell
@@ -104148,7 +104217,7 @@ async function runGenCommand(rerouteCmd, useShell, noCompression) {
104148
104217
  if (code !== null && code !== 0) {
104149
104218
  reject(new Error(`Gen exited with code ${code}`));
104150
104219
  } else {
104151
- resolve2();
104220
+ resolve3();
104152
104221
  }
104153
104222
  });
104154
104223
  genProcess.on("error", (error) => {
@@ -104319,7 +104388,7 @@ __export(exports_analyze, {
104319
104388
  default: () => analyze
104320
104389
  });
104321
104390
  import { existsSync as existsSync11, statSync } from "node:fs";
104322
- import { readdir as readdir8, readFile, stat as stat5, writeFile } from "node:fs/promises";
104391
+ import { readdir as readdir8, readFile, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
104323
104392
  import { basename as basename3, join as join16, relative as relative3 } from "node:path";
104324
104393
  import Table from "cli-table3";
104325
104394
  async function findChunkBundles(cwd) {
@@ -104426,11 +104495,11 @@ async function findBrowserEntry(cwd) {
104426
104495
  const code = await output.text();
104427
104496
  const actualHash = await generateContentHash2(code);
104428
104497
  const bundlePath = join16(tempDir, `index.${actualHash}.js`);
104429
- await writeFile(bundlePath, code, "utf-8");
104498
+ await writeFile2(bundlePath, code, "utf-8");
104430
104499
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
104431
104500
  if (mapOutput) {
104432
104501
  const mapContent = await mapOutput.text();
104433
- await writeFile(`${bundlePath}.map`, mapContent, "utf-8");
104502
+ await writeFile2(`${bundlePath}.map`, mapContent, "utf-8");
104434
104503
  }
104435
104504
  return bundlePath;
104436
104505
  } catch (error) {
@@ -106348,7 +106417,7 @@ async function analyze(args) {
106348
106417
  const useShell = rerouteCmd.includes(" ");
106349
106418
  const buildCommand = useShell ? `${rerouteCmd} build` : rerouteCmd;
106350
106419
  const buildArgs = useShell ? [] : ["build"];
106351
- await new Promise((resolve2, reject) => {
106420
+ await new Promise((resolve3, reject) => {
106352
106421
  const buildProcess = spawn4(buildCommand, buildArgs, {
106353
106422
  stdio: "inherit",
106354
106423
  shell: useShell
@@ -106357,7 +106426,7 @@ async function analyze(args) {
106357
106426
  if (code !== null && code !== 0) {
106358
106427
  reject(new Error(`Build exited with code ${code}`));
106359
106428
  } else {
106360
- resolve2();
106429
+ resolve3();
106361
106430
  }
106362
106431
  });
106363
106432
  buildProcess.on("error", (error) => {
@@ -106420,11 +106489,11 @@ async function analyze(args) {
106420
106489
  const output = result.outputs[0];
106421
106490
  const code = await output.text();
106422
106491
  const analysisEntry = join16(serverAnalysisDir, "index.js");
106423
- await writeFile(analysisEntry, code, "utf-8");
106492
+ await writeFile2(analysisEntry, code, "utf-8");
106424
106493
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
106425
106494
  if (mapOutput) {
106426
106495
  const mapContent = await mapOutput.text();
106427
- await writeFile(`${analysisEntry}.map`, mapContent, "utf-8");
106496
+ await writeFile2(`${analysisEntry}.map`, mapContent, "utf-8");
106428
106497
  }
106429
106498
  entry = analysisEntry;
106430
106499
  }
@@ -106484,7 +106553,7 @@ async function analyze(args) {
106484
106553
  const html2 = await generateHTMLReport(stats, depTree, mainInfo, browserDepTree, browserInfo, initialSearch);
106485
106554
  const { mkdir: mkdir4 } = await import("node:fs/promises");
106486
106555
  await mkdir4(join16(cwd, ".reroute"), { recursive: true });
106487
- await writeFile(htmlPath, html2, "utf-8");
106556
+ await writeFile2(htmlPath, html2, "utf-8");
106488
106557
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] HTML report generated: ${relative3(cwd, htmlPath)}
106489
106558
  `));
106490
106559
  if (openBrowser) {
@@ -106563,8 +106632,8 @@ async function killProcessOnPort(port) {
106563
106632
  const proc = spawn4("bunx", ["kill-port", String(port)], {
106564
106633
  stdio: "ignore"
106565
106634
  });
106566
- await new Promise((resolve2) => {
106567
- proc.on("close", () => resolve2());
106635
+ await new Promise((resolve3) => {
106636
+ proc.on("close", () => resolve3());
106568
106637
  });
106569
106638
  } catch {}
106570
106639
  }
@@ -106928,7 +106997,7 @@ async function getVersionString2() {
106928
106997
  }
106929
106998
  async function getVersion2() {
106930
106999
  if (true) {
106931
- return "1.0.0-alpha.0";
107000
+ return "1.0.0-alpha.2";
106932
107001
  }
106933
107002
  const possiblePaths = [
106934
107003
  path3.join(import.meta.dir, "../../../package.json"),
@@ -106945,10 +107014,10 @@ async function getVersion2() {
106945
107014
  }
106946
107015
  async function getCommit2() {
106947
107016
  if (true) {
106948
- return "9abafce";
107017
+ return "3e34125";
106949
107018
  }
106950
107019
  return "dev";
106951
107020
  }
106952
107021
  main();
106953
107022
 
106954
- //# debugId=CA92814D9FB7179764756E2164756E21
107023
+ //# debugId=CC941DD40B19367864756E2164756E21