reroute-js 0.0.4 → 0.0.6

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.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
+ import { createRequire } from "node:module";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __export = (target, all) => {
5
6
  for (var name in all)
@@ -11,6 +12,7 @@ var __export = (target, all) => {
11
12
  });
12
13
  };
13
14
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
15
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
16
 
15
17
  // packages/cli/src/commands/init.ts
16
18
  var exports_init = {};
@@ -110,7 +112,7 @@ async function copyTemplateFiles(templatePath, targetPath, variables) {
110
112
  }
111
113
  function printSuccess(projectName, template) {
112
114
  console.log(`
113
- Project created successfully!
115
+ [✓] Project created successfully!
114
116
  `);
115
117
  console.log(`Next steps:
116
118
  `);
@@ -192,37 +194,220 @@ async function dev(_args) {
192
194
  console.log("");
193
195
  console.log("For now, please use your own dev server setup or check the examples.");
194
196
  }
197
+ // packages/core/src/bundler/transpile.ts
198
+ var init_transpile = () => {};
195
199
 
196
- // packages/cli/src/libs/tailwind.ts
200
+ // packages/core/src/bundler/index.ts
201
+ var init_bundler = __esm(() => {
202
+ init_transpile();
203
+ });
204
+
205
+ // packages/core/src/content/builder.ts
206
+ var init_builder = () => {};
207
+
208
+ // packages/core/src/content/metadata.ts
209
+ var init_metadata = () => {};
210
+
211
+ // packages/core/src/content/discovery.ts
212
+ var init_discovery = __esm(() => {
213
+ init_metadata();
214
+ });
215
+
216
+ // packages/core/src/content/registry.ts
217
+ var init_registry = () => {};
218
+
219
+ // packages/core/src/content/index.ts
220
+ var init_content = __esm(() => {
221
+ init_builder();
222
+ init_discovery();
223
+ init_metadata();
224
+ init_registry();
225
+ });
226
+
227
+ // packages/core/src/ssr/modules.ts
228
+ var init_modules = () => {};
229
+
230
+ // packages/core/src/ssr/seed.ts
231
+ var init_seed = __esm(() => {
232
+ init_modules();
233
+ });
234
+
235
+ // packages/core/src/ssr/data.ts
236
+ var init_data = __esm(() => {
237
+ init_seed();
238
+ });
239
+
240
+ // node_modules/dedent/dist/dedent.mjs
241
+ function ownKeys(object, enumerableOnly) {
242
+ var keys = Object.keys(object);
243
+ if (Object.getOwnPropertySymbols) {
244
+ var symbols = Object.getOwnPropertySymbols(object);
245
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
246
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
247
+ })), keys.push.apply(keys, symbols);
248
+ }
249
+ return keys;
250
+ }
251
+ function _objectSpread(target) {
252
+ for (var i = 1;i < arguments.length; i++) {
253
+ var source = arguments[i] != null ? arguments[i] : {};
254
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
255
+ _defineProperty(target, key, source[key]);
256
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
257
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
258
+ });
259
+ }
260
+ return target;
261
+ }
262
+ function _defineProperty(obj, key, value) {
263
+ key = _toPropertyKey(key);
264
+ if (key in obj) {
265
+ Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
266
+ } else {
267
+ obj[key] = value;
268
+ }
269
+ return obj;
270
+ }
271
+ function _toPropertyKey(arg) {
272
+ var key = _toPrimitive(arg, "string");
273
+ return typeof key === "symbol" ? key : String(key);
274
+ }
275
+ function _toPrimitive(input, hint) {
276
+ if (typeof input !== "object" || input === null)
277
+ return input;
278
+ var prim = input[Symbol.toPrimitive];
279
+ if (prim !== undefined) {
280
+ var res = prim.call(input, hint || "default");
281
+ if (typeof res !== "object")
282
+ return res;
283
+ throw new TypeError("@@toPrimitive must return a primitive value.");
284
+ }
285
+ return (hint === "string" ? String : Number)(input);
286
+ }
287
+ function createDedent(options) {
288
+ dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
289
+ return dedent2;
290
+ function dedent2(strings, ...values) {
291
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
292
+ const {
293
+ alignValues = false,
294
+ escapeSpecialCharacters = Array.isArray(strings),
295
+ trimWhitespace = true
296
+ } = options;
297
+ let result = "";
298
+ for (let i = 0;i < raw.length; i++) {
299
+ let next = raw[i];
300
+ if (escapeSpecialCharacters) {
301
+ next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
302
+ }
303
+ result += next;
304
+ if (i < values.length) {
305
+ const value = alignValues ? alignValue(values[i], result) : values[i];
306
+ result += value;
307
+ }
308
+ }
309
+ const lines = result.split(`
310
+ `);
311
+ let mindent = null;
312
+ for (const l of lines) {
313
+ const m = l.match(/^(\s+)\S+/);
314
+ if (m) {
315
+ const indent = m[1].length;
316
+ if (!mindent) {
317
+ mindent = indent;
318
+ } else {
319
+ mindent = Math.min(mindent, indent);
320
+ }
321
+ }
322
+ }
323
+ if (mindent !== null) {
324
+ const m = mindent;
325
+ result = lines.map((l) => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join(`
326
+ `);
327
+ }
328
+ if (trimWhitespace) {
329
+ result = result.trim();
330
+ }
331
+ if (escapeSpecialCharacters) {
332
+ result = result.replace(/\\n/g, `
333
+ `);
334
+ }
335
+ return result;
336
+ }
337
+ }
338
+ function alignValue(value, precedingText) {
339
+ if (typeof value !== "string" || !value.includes(`
340
+ `)) {
341
+ return value;
342
+ }
343
+ const currentLine = precedingText.slice(precedingText.lastIndexOf(`
344
+ `) + 1);
345
+ const indentMatch = currentLine.match(/^(\s+)/);
346
+ if (indentMatch) {
347
+ const indent = indentMatch[1];
348
+ return value.replace(/\n/g, `
349
+ ${indent}`);
350
+ }
351
+ return value;
352
+ }
353
+ var dedent;
354
+ var init_dedent = __esm(() => {
355
+ dedent = createDedent({});
356
+ });
357
+
358
+ // packages/core/src/template/html.ts
359
+ var init_html = () => {};
360
+
361
+ // packages/core/src/template/index.ts
362
+ var init_template = __esm(() => {
363
+ init_html();
364
+ });
365
+
366
+ // packages/core/src/ssr/render.ts
367
+ import { cloneElement } from "react";
368
+ import { renderToString } from "react-dom/server";
369
+ var init_render = __esm(() => {
370
+ init_dedent();
371
+ init_metadata();
372
+ init_template();
373
+ init_seed();
374
+ });
375
+
376
+ // packages/core/src/ssr/index.ts
377
+ var init_ssr = __esm(() => {
378
+ init_data();
379
+ init_render();
380
+ init_seed();
381
+ });
382
+
383
+ // packages/core/src/tailwind.ts
197
384
  import { spawn } from "node:child_process";
198
385
  import { existsSync as existsSync2, readFileSync } from "node:fs";
199
- import { join as join2 } from "node:path";
386
+ import { join as join3 } from "node:path";
200
387
  function isTailwindAvailable(cwd) {
201
- const packageJsonPath = join2(cwd, "package.json");
202
- if (!existsSync2(packageJsonPath)) {
388
+ const packageJsonPath = join3(cwd, "package.json");
389
+ if (!existsSync2(packageJsonPath))
203
390
  return false;
204
- }
205
391
  try {
206
392
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
207
393
  const deps = {
208
394
  ...packageJson.dependencies,
209
395
  ...packageJson.devDependencies
210
396
  };
211
- return "@tailwindcss/cli" in deps;
397
+ return !!deps && "@tailwindcss/cli" in deps;
212
398
  } catch {
213
399
  return false;
214
400
  }
215
401
  }
216
402
  function getTailwindPaths(cwd) {
217
- const input = join2(cwd, "src/client/theme.css");
218
- const output = join2(cwd, ".reroute/theme.css");
403
+ const input = join3(cwd, "src/client/theme.css");
404
+ const output = join3(cwd, ".reroute/theme.css");
219
405
  return { input, output };
220
406
  }
221
407
  function hasTailwindInput(cwd) {
222
408
  const { input } = getTailwindPaths(cwd);
223
- if (!existsSync2(input)) {
409
+ if (!existsSync2(input))
224
410
  return false;
225
- }
226
411
  try {
227
412
  const content = readFileSync(input, "utf-8");
228
413
  return content.includes('@import "tailwindcss"');
@@ -232,57 +417,72 @@ function hasTailwindInput(cwd) {
232
417
  }
233
418
  function resolveTailwindBin(cwd) {
234
419
  const pathsToTry = [
235
- join2(cwd, "node_modules/.bin/tailwindcss"),
236
- join2(cwd, "../node_modules/.bin/tailwindcss"),
237
- join2(cwd, "../../node_modules/.bin/tailwindcss"),
238
- join2(cwd, "../../../node_modules/.bin/tailwindcss")
420
+ join3(cwd, "node_modules/.bin/tailwindcss"),
421
+ join3(cwd, "../node_modules/.bin/tailwindcss"),
422
+ join3(cwd, "../../node_modules/.bin/tailwindcss"),
423
+ join3(cwd, "../../../node_modules/.bin/tailwindcss")
239
424
  ];
240
- for (const binPath of pathsToTry) {
241
- if (existsSync2(binPath)) {
425
+ for (const binPath of pathsToTry)
426
+ if (existsSync2(binPath))
242
427
  return binPath;
243
- }
244
- }
245
- return join2(cwd, "node_modules/.bin/tailwindcss");
428
+ return join3(cwd, "node_modules/.bin/tailwindcss");
246
429
  }
247
430
  async function buildTailwind(cwd) {
248
431
  const { input, output } = getTailwindPaths(cwd);
249
- return new Promise((resolve, reject) => {
432
+ if (!isTailwindAvailable(cwd) || !hasTailwindInput(cwd))
433
+ return;
434
+ await new Promise((resolve, reject) => {
250
435
  const tailwindBin = resolveTailwindBin(cwd);
251
436
  const args = ["-i", input, "-o", output];
252
- const tailwind = spawn(tailwindBin, args, {
253
- cwd,
254
- stdio: "inherit"
255
- });
256
- tailwind.on("close", (code) => {
257
- if (code === 0) {
258
- resolve();
259
- } else {
260
- reject(new Error(`Tailwind CSS build failed with code ${code}`));
261
- }
262
- });
263
- tailwind.on("error", (error) => {
264
- reject(error);
265
- });
437
+ const tailwind = spawn(tailwindBin, args, { cwd, stdio: "inherit" });
438
+ tailwind.on("close", (code) => code === 0 ? resolve() : reject(new Error(`Tailwind CSS build failed with code ${code}`)));
439
+ tailwind.on("error", (error) => reject(error));
266
440
  });
267
441
  }
442
+ var init_tailwind = () => {};
443
+ // packages/core/src/utils/cache.ts
444
+ var init_cache = () => {};
445
+ // packages/core/src/utils/compression.ts
446
+ var init_compression = () => {};
447
+
448
+ // packages/core/src/utils/index.ts
449
+ var init_utils = __esm(() => {
450
+ init_cache();
451
+ init_compression();
452
+ });
453
+
454
+ // packages/core/src/index.ts
455
+ var init_src = __esm(() => {
456
+ init_bundler();
457
+ init_content();
458
+ init_ssr();
459
+ init_tailwind();
460
+ init_template();
461
+ init_utils();
462
+ });
463
+
464
+ // packages/core/index.ts
465
+ var init_core = __esm(() => {
466
+ init_src();
467
+ });
468
+
469
+ // packages/cli/src/libs/tailwind.ts
268
470
  function watchTailwind(cwd) {
269
471
  const { input, output } = getTailwindPaths(cwd);
270
472
  const tailwindBin = resolveTailwindBin(cwd);
271
473
  const args = ["-i", input, "-o", output, "--watch"];
272
474
  console.log("[reroute/tailwind] Starting Tailwind CSS v4 in watch mode...");
273
- const tailwind = spawn(tailwindBin, args, {
274
- cwd,
275
- stdio: "inherit"
276
- });
277
- tailwind.on("error", (error) => {
475
+ const { spawn: spawn2 } = __require("node:child_process");
476
+ const tailwind2 = spawn2(tailwindBin, args, { cwd, stdio: "inherit" });
477
+ tailwind2.on("error", (error) => {
278
478
  console.error("[reroute/tailwind] Error:", error);
279
479
  });
280
480
  const stop = () => {
281
481
  console.log("[reroute/tailwind] Stopping Tailwind CSS...");
282
- tailwind.kill();
482
+ tailwind2.kill();
283
483
  };
284
484
  return {
285
- process: tailwind,
485
+ process: tailwind2,
286
486
  stop
287
487
  };
288
488
  }
@@ -305,7 +505,9 @@ function initTailwind(cwd, watch = false) {
305
505
  });
306
506
  return null;
307
507
  }
308
- var init_tailwind = () => {};
508
+ var init_tailwind2 = __esm(() => {
509
+ init_core();
510
+ });
309
511
 
310
512
  // packages/cli/src/commands/gen.ts
311
513
  var exports_gen = {};
@@ -314,21 +516,21 @@ __export(exports_gen, {
314
516
  });
315
517
  import { watch } from "node:fs";
316
518
  import { mkdir as mkdir2, readdir as readdir2, rm, writeFile as writeFile2 } from "node:fs/promises";
317
- import { join as join3 } from "node:path";
519
+ import { join as join4 } from "node:path";
318
520
  import { pathToFileURL } from "node:url";
319
521
  async function cleanupOutputDir(cwd) {
320
- const outputPath = join3(cwd, OUTPUT_DIR);
321
522
  try {
322
- await rm(outputPath, { recursive: true, force: true });
323
- console.log(`[reroute/gen] Cleaned up ${outputPath}`);
523
+ await rm(join4(cwd, OUTPUT_DIR), { force: true });
524
+ await mkdir2(join4(cwd, OUTPUT_DIR), { recursive: true });
525
+ console.log("[reroute/gen] Cleaned up generated artifacts in .reroute");
324
526
  } catch {}
325
527
  }
326
528
  async function scanDirectory(dir, base = "") {
327
529
  const files = [];
328
530
  const entries = await readdir2(dir, { withFileTypes: true });
329
531
  for (const entry of entries) {
330
- const fullPath = join3(dir, entry.name);
331
- const relativePath = join3(base, entry.name);
532
+ const fullPath = join4(dir, entry.name);
533
+ const relativePath = join4(base, entry.name);
332
534
  if (entry.isDirectory()) {
333
535
  if (entry.name === "content")
334
536
  continue;
@@ -349,8 +551,8 @@ async function scan404Files(dir, base = "") {
349
551
  const files = [];
350
552
  const entries = await readdir2(dir, { withFileTypes: true });
351
553
  for (const entry of entries) {
352
- const fullPath = join3(dir, entry.name);
353
- const relativePath = join3(base, entry.name);
554
+ const fullPath = join4(dir, entry.name);
555
+ const relativePath = join4(base, entry.name);
354
556
  if (entry.isDirectory()) {
355
557
  const nested = await scan404Files(fullPath, relativePath);
356
558
  files.push(...nested);
@@ -541,15 +743,15 @@ async function listContentFiles(collectionDir) {
541
743
  }
542
744
  }
543
745
  async function sha8(text) {
544
- const data = new TextEncoder().encode(text);
545
- const buf = await crypto.subtle.digest("SHA-256", data);
746
+ const data2 = new TextEncoder().encode(text);
747
+ const buf = await crypto.subtle.digest("SHA-256", data2);
546
748
  let hex = "";
547
749
  for (const b of new Uint8Array(buf))
548
750
  hex += b.toString(16).padStart(2, "0");
549
751
  return hex.slice(0, 8);
550
752
  }
551
753
  async function buildContentChunks(cwd) {
552
- const routesRoot = join3(cwd, ROUTES_DIR);
754
+ const routesRoot = join4(cwd, ROUTES_DIR);
553
755
  console.log(`[reroute/content] scan ${routesRoot}`);
554
756
  const collections = await readdir2(routesRoot, { withFileTypes: true });
555
757
  const results = [];
@@ -557,7 +759,7 @@ async function buildContentChunks(cwd) {
557
759
  if (!c.isDirectory())
558
760
  continue;
559
761
  const collection = c.name;
560
- const contentDir = join3(routesRoot, collection, "content");
762
+ const contentDir = join4(routesRoot, collection, "content");
561
763
  console.log(`[reroute/content] collection ${collection} dir ${contentDir}`);
562
764
  const files = await listContentFiles(contentDir);
563
765
  console.log(`[reroute/content] files ${files.join(",")}`);
@@ -565,7 +767,7 @@ async function buildContentChunks(cwd) {
565
767
  continue;
566
768
  for (const file of files) {
567
769
  const name = file.replace(/\.(tsx|ts)$/, "");
568
- const absSrc = join3(contentDir, file);
770
+ const absSrc = join4(contentDir, file);
569
771
  let code = "";
570
772
  try {
571
773
  console.log(`[reroute/content] build ${absSrc}`);
@@ -585,11 +787,11 @@ async function buildContentChunks(cwd) {
585
787
  console.error("[reroute/gen] Failed to build content chunk:", absSrc, e);
586
788
  continue;
587
789
  }
588
- const hash = await sha8(code);
589
- const chunkRelDir = join3(".reroute", "chunks", collection);
590
- const chunkAbsDir = join3(cwd, chunkRelDir);
591
- const outFile = `${name}.${hash}.js`;
592
- const absOut = join3(chunkAbsDir, outFile);
790
+ const hash2 = await sha8(code);
791
+ const chunkRelDir = join4(".reroute", "chunks", collection);
792
+ const chunkAbsDir = join4(cwd, chunkRelDir);
793
+ const outFile = `${name}.${hash2}.js`;
794
+ const absOut = join4(chunkAbsDir, outFile);
593
795
  await mkdir2(chunkAbsDir, { recursive: true });
594
796
  try {
595
797
  const exists = await Bun.file(absOut).exists();
@@ -639,12 +841,12 @@ async function buildContentChunks(cwd) {
639
841
  lines.push(" return m ? (m as Record<string, any>)[name] : undefined;");
640
842
  lines.push("}");
641
843
  lines.push("");
642
- await mkdir2(join3(cwd, ".reroute"), { recursive: true });
643
- await writeFile2(join3(cwd, OUTPUT_CONTENT_TS), lines.join(`
844
+ await mkdir2(join4(cwd, ".reroute"), { recursive: true });
845
+ await writeFile2(join4(cwd, OUTPUT_CONTENT_TS), lines.join(`
644
846
  `), "utf-8");
645
- console.log(`[reroute/content] wrote ${join3(cwd, OUTPUT_CONTENT_TS)}`);
847
+ console.log(`[reroute/content] wrote ${join4(cwd, OUTPUT_CONTENT_TS)}`);
646
848
  const collectionsSet = new Set(results.map((r) => r.collection));
647
- await mkdir2(join3(cwd, OUTPUT_COLLECTIONS_DIR), { recursive: true });
849
+ await mkdir2(join4(cwd, OUTPUT_COLLECTIONS_DIR), { recursive: true });
648
850
  for (const collection of collectionsSet) {
649
851
  const items = results.filter((r) => r.collection === collection);
650
852
  const js = [];
@@ -664,31 +866,31 @@ async function buildContentChunks(cwd) {
664
866
  js.push(" return byName[name];");
665
867
  js.push("}");
666
868
  js.push("");
667
- await writeFile2(join3(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`), js.join(`
869
+ await writeFile2(join4(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`), js.join(`
668
870
  `), "utf-8");
669
- console.log(`[reroute/content] wrote ${join3(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`)}`);
871
+ console.log(`[reroute/content] wrote ${join4(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`)}`);
670
872
  }
671
873
  }
672
874
  async function generate(cwd) {
673
875
  console.log("[reroute/gen] Starting generation...");
674
876
  await cleanupOutputDir(cwd);
675
- const routesPath = join3(cwd, ROUTES_DIR);
877
+ const routesPath = join4(cwd, ROUTES_DIR);
676
878
  try {
677
879
  const files = await scanDirectory(routesPath);
678
880
  const nfFiles = await scan404Files(routesPath);
679
881
  const all = Array.from(new Set([...files, ...nfFiles]));
680
882
  const tree = generateRouteTree(all.map((f) => f.replace(/\\/g, "/")));
681
883
  const ts = generateTypeScript(tree);
682
- await mkdir2(join3(cwd, ".reroute"), { recursive: true });
683
- await writeFile2(join3(cwd, OUTPUT_ROUTES), ts, "utf-8");
684
- console.log(`[reroute/gen] Generated routes: ${join3(cwd, OUTPUT_ROUTES)}`);
884
+ await mkdir2(join4(cwd, ".reroute"), { recursive: true });
885
+ await writeFile2(join4(cwd, OUTPUT_ROUTES), ts, "utf-8");
886
+ console.log(`[reroute/gen] Generated routes: ${join4(cwd, OUTPUT_ROUTES)}`);
685
887
  } catch (error) {
686
888
  console.error("[reroute/gen] Failed to generate routes:", error);
687
889
  throw error;
688
890
  }
689
891
  try {
690
892
  await buildContentChunks(cwd);
691
- console.log(`[reroute/gen] Generated content: ${join3(cwd, OUTPUT_CONTENT_TS)} + collections/*.js`);
893
+ console.log(`[reroute/gen] Generated content: ${join4(cwd, OUTPUT_CONTENT_TS)} + collections/*.js`);
692
894
  } catch (error) {
693
895
  console.error("[reroute/gen] Failed to generate content:", error);
694
896
  throw error;
@@ -708,9 +910,9 @@ async function generate(cwd) {
708
910
  indexLines.push("} as const;");
709
911
  indexLines.push("");
710
912
  indexLines.push("export type RerouteArtifacts = typeof artifacts;");
711
- await writeFile2(join3(cwd, OUTPUT_INDEX), indexLines.join(`
913
+ await writeFile2(join4(cwd, OUTPUT_INDEX), indexLines.join(`
712
914
  `), "utf-8");
713
- console.log(`[reroute/gen] Generated index: ${join3(cwd, OUTPUT_INDEX)}`);
915
+ console.log(`[reroute/gen] Generated index: ${join4(cwd, OUTPUT_INDEX)}`);
714
916
  console.log("[reroute/gen] ✅ Generation complete!");
715
917
  }
716
918
  async function gen(args) {
@@ -720,8 +922,10 @@ async function gen(args) {
720
922
  console.log("[reroute/gen] Watch mode enabled");
721
923
  console.log("[reroute/gen] Initial generation...");
722
924
  await generate(cwd);
723
- const tailwindProcess = initTailwind(cwd, true);
724
- const routesPath = join3(cwd, ROUTES_DIR);
925
+ try {
926
+ await buildTailwind(cwd);
927
+ } catch {}
928
+ const routesPath = join4(cwd, ROUTES_DIR);
725
929
  console.log(`[reroute/gen] Watching ${routesPath} for changes...`);
726
930
  let timeout = null;
727
931
  const watcher = watch(routesPath, { recursive: true }, (_eventType, filename) => {
@@ -733,18 +937,37 @@ async function gen(args) {
733
937
  console.log("[reroute/gen] Change detected, regenerating...");
734
938
  try {
735
939
  await generate(cwd);
940
+ await buildTailwind(cwd);
736
941
  } catch (error) {
737
942
  console.error("[reroute/gen] Error during regeneration:", error);
738
943
  }
739
- }, 300);
944
+ }, 0);
945
+ });
946
+ const clientPath = join4(cwd, "src", "client");
947
+ console.log(`[reroute/gen] Watching ${clientPath} for Tailwind class changes...`);
948
+ let twTimeout = null;
949
+ const twWatcher = watch(clientPath, { recursive: true }, (_eventType, filename) => {
950
+ if (!filename)
951
+ return;
952
+ if (filename.includes(".reroute") || filename.includes("node_modules"))
953
+ return;
954
+ if (filename.includes("routes/") || filename.includes("routes\\"))
955
+ return;
956
+ if (!/\.(tsx|ts|jsx|js|html|md|mdx|css)$/.test(filename))
957
+ return;
958
+ if (twTimeout)
959
+ clearTimeout(twTimeout);
960
+ twTimeout = setTimeout(async () => {
961
+ try {
962
+ await buildTailwind(cwd);
963
+ } catch {}
964
+ }, 200);
740
965
  });
741
966
  process.on("SIGINT", () => {
742
967
  console.log(`
743
968
  [reroute/gen] Stopping watch mode...`);
744
969
  watcher.close();
745
- if (tailwindProcess) {
746
- tailwindProcess.stop();
747
- }
970
+ twWatcher.close();
748
971
  process.exit(0);
749
972
  });
750
973
  } else {
@@ -754,7 +977,8 @@ async function gen(args) {
754
977
  }
755
978
  var ROUTES_DIR = "src/client/routes", OUTPUT_DIR = ".reroute", OUTPUT_ROUTES = ".reroute/routes.ts", OUTPUT_CONTENT_TS = ".reroute/content.ts", OUTPUT_COLLECTIONS_DIR = ".reroute/collections", OUTPUT_INDEX = ".reroute/index.ts";
756
979
  var init_gen = __esm(() => {
757
- init_tailwind();
980
+ init_core();
981
+ init_tailwind2();
758
982
  });
759
983
 
760
984
  // packages/cli/src/index.ts
@@ -809,4 +1033,4 @@ function printHelp2() {
809
1033
  }
810
1034
  main();
811
1035
 
812
- //# debugId=C29E5DC549E7785F64756E2164756E21
1036
+ //# debugId=D904E39CF66BD8B664756E2164756E21