@farm.js/core 0.1.0-beta.13 → 0.1.0-beta.14

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.
@@ -31,7 +31,7 @@ import {
31
31
  mergeFarmFontCss,
32
32
  mergeFarmViteConfig,
33
33
  resolveRouteRenderingConfigFromFile
34
- } from "./chunk-Z3YG4OZT.mjs";
34
+ } from "./chunk-PNFQQSRA.mjs";
35
35
  import {
36
36
  farmEnvironmentFunctionsPlugin
37
37
  } from "./chunk-V6WE6JSZ.mjs";
@@ -6585,4 +6585,4 @@ __name(buildNitro, "buildNitro");
6585
6585
  export {
6586
6586
  build
6587
6587
  };
6588
- //# sourceMappingURL=chunk-VSDZEB5M.mjs.map
6588
+ //# sourceMappingURL=chunk-VUL55IAX.mjs.map
package/dist/index.cjs CHANGED
@@ -17846,39 +17846,48 @@ async function createRouteTypeDeclarations(options, outPath) {
17846
17846
  const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
17847
17847
  const sourceRoots = options.sourceRoots ?? [{ name: "project", root, srcDir, layer: false }];
17848
17848
  const patterns = /* @__PURE__ */ new Set();
17849
+ const routeModulePatterns = /* @__PURE__ */ new Set();
17849
17850
  const glob = await import("fast-glob");
17850
17851
  for (const source of sourceRoots) {
17851
17852
  const appDir = path14.join(source.root, source.srcDir, "app");
17852
17853
  if (fs5.existsSync(appDir)) {
17853
- const pageFiles = await glob.default("**/page.{ts,tsx,js,jsx,md,mdx}", {
17854
- cwd: appDir,
17855
- absolute: false
17856
- });
17857
- for (const file of pageFiles) {
17854
+ const routeModuleFiles = await glob.default(
17855
+ "**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
17856
+ {
17857
+ cwd: appDir,
17858
+ absolute: false
17859
+ }
17860
+ );
17861
+ for (const file of routeModuleFiles) {
17858
17862
  if (parseRouteSlotFile(file)) continue;
17859
17863
  const route2 = parseRoutePath(file);
17864
+ const pattern = createRoutePattern(route2);
17865
+ routeModulePatterns.add(pattern);
17860
17866
  if (route2.type === "page") {
17861
- const pattern = createRoutePattern(route2);
17862
17867
  patterns.add(pattern);
17863
17868
  }
17864
17869
  }
17865
17870
  }
17866
17871
  for (const route2 of await discoverProgrammaticRoutePaths(source.root, source.srcDir)) {
17867
17872
  patterns.add(route2);
17873
+ routeModulePatterns.add(route2);
17868
17874
  }
17869
17875
  }
17870
17876
  for (const route2 of extraRoutes) {
17871
17877
  if (route2.startsWith("/")) {
17872
17878
  patterns.add(route2);
17879
+ routeModulePatterns.add(route2);
17873
17880
  }
17874
17881
  }
17875
17882
  const sortedPatterns = Array.from(patterns).sort();
17876
17883
  const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
17877
17884
  const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
17885
+ const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
17878
17886
  const routePathType = suppressLintOnLink ? "string" : typeLiterals.length ? typeLiterals.join(" | ") : "never";
17879
17887
  const routePatternType = suppressLintOnLink ? "string" : patternLiterals.length ? patternLiterals.join(" | ") : "never";
17888
+ const routeModulePatternType = routeModulePatternLiterals.length ? routeModulePatternLiterals.join(" | ") : "never";
17880
17889
  const routeTypesImportPath = `./${path14.basename(outPath).replace(/\.d\.ts$/, "")}`;
17881
- const augmentationBlock = suppressLintOnLink ? "" : `
17890
+ const linkAugmentationBlock = suppressLintOnLink ? "" : `
17882
17891
  declare module "@farm.js/core/client" {
17883
17892
  interface LinkDefaultRoute {
17884
17893
  _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
@@ -17902,14 +17911,25 @@ declare module "@farm.js/core/dist/client.js" {
17902
17911
  pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
17903
17912
  }
17904
17913
  }
17914
+ `;
17915
+ const routeModuleAugmentationBlock = `
17916
+ declare global {
17917
+ namespace FarmJS {
17918
+ interface RouteRegistry {
17919
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RouteModulePattern;
17920
+ }
17921
+ }
17922
+ }
17905
17923
  `;
17906
17924
  const content = `/**
17907
17925
  * Auto-generated route types from src/app.
17908
- * Link href is typed automatically via module augmentation. Regenerated on dev start and when routes change.
17926
+ * Link href and route component props are typed automatically from generated declarations.
17927
+ * Regenerated on dev start and when routes change.
17909
17928
  * Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
17910
17929
  */
17911
17930
  export type RoutePath = ${routePathType};
17912
- export type RoutePattern = ${routePatternType};${augmentationBlock}
17931
+ export type RoutePattern = ${routePatternType};
17932
+ export type RouteModulePattern = ${routeModulePatternType};${linkAugmentationBlock}${routeModuleAugmentationBlock}
17913
17933
  `;
17914
17934
  return content;
17915
17935
  }
@@ -18708,7 +18728,7 @@ var init_environment_vite = __esm({
18708
18728
  var version;
18709
18729
  var init_package = __esm({
18710
18730
  "package.json"() {
18711
- version = "0.1.0-beta.13";
18731
+ version = "0.1.0-beta.14";
18712
18732
  }
18713
18733
  });
18714
18734