@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.
package/dist/plugin.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import "./chunk-RQ633A5I.mjs";
6
6
  import {
7
7
  farmPlugin
8
- } from "./chunk-Z3YG4OZT.mjs";
8
+ } from "./chunk-PNFQQSRA.mjs";
9
9
  import "./chunk-LGHEOHBU.mjs";
10
10
  import "./chunk-FRPWCMMG.mjs";
11
11
  import "./chunk-53MVSX3R.mjs";
@@ -45,7 +45,7 @@ import "./chunk-J4FNJ5IU.mjs";
45
45
  import "./chunk-PFE6GMNE.mjs";
46
46
  import "./chunk-RHIFZZUI.mjs";
47
47
  import "./chunk-LM2YNO4U.mjs";
48
- import "./chunk-3WIRO3N7.mjs";
48
+ import "./chunk-ARCGE2VT.mjs";
49
49
  import "./chunk-KLA67WKG.mjs";
50
50
  import "./chunk-ITN462YM.mjs";
51
51
  import "./chunk-B232I2GP.mjs";
package/dist/server.cjs CHANGED
@@ -22986,39 +22986,48 @@ async function createRouteTypeDeclarations(options, outPath) {
22986
22986
  const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
22987
22987
  const sourceRoots = options.sourceRoots ?? [{ name: "project", root, srcDir, layer: false }];
22988
22988
  const patterns = /* @__PURE__ */ new Set();
22989
+ const routeModulePatterns = /* @__PURE__ */ new Set();
22989
22990
  const glob = await import("fast-glob");
22990
22991
  for (const source of sourceRoots) {
22991
22992
  const appDir = path14.join(source.root, source.srcDir, "app");
22992
22993
  if (fs5.existsSync(appDir)) {
22993
- const pageFiles = await glob.default("**/page.{ts,tsx,js,jsx,md,mdx}", {
22994
- cwd: appDir,
22995
- absolute: false
22996
- });
22997
- for (const file of pageFiles) {
22994
+ const routeModuleFiles = await glob.default(
22995
+ "**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
22996
+ {
22997
+ cwd: appDir,
22998
+ absolute: false
22999
+ }
23000
+ );
23001
+ for (const file of routeModuleFiles) {
22998
23002
  if (parseRouteSlotFile(file)) continue;
22999
23003
  const route = parseRoutePath(file);
23004
+ const pattern = createRoutePattern(route);
23005
+ routeModulePatterns.add(pattern);
23000
23006
  if (route.type === "page") {
23001
- const pattern = createRoutePattern(route);
23002
23007
  patterns.add(pattern);
23003
23008
  }
23004
23009
  }
23005
23010
  }
23006
23011
  for (const route of await discoverProgrammaticRoutePaths(source.root, source.srcDir)) {
23007
23012
  patterns.add(route);
23013
+ routeModulePatterns.add(route);
23008
23014
  }
23009
23015
  }
23010
23016
  for (const route of extraRoutes) {
23011
23017
  if (route.startsWith("/")) {
23012
23018
  patterns.add(route);
23019
+ routeModulePatterns.add(route);
23013
23020
  }
23014
23021
  }
23015
23022
  const sortedPatterns = Array.from(patterns).sort();
23016
23023
  const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
23017
23024
  const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
23025
+ const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
23018
23026
  const routePathType = suppressLintOnLink ? "string" : typeLiterals.length ? typeLiterals.join(" | ") : "never";
23019
23027
  const routePatternType = suppressLintOnLink ? "string" : patternLiterals.length ? patternLiterals.join(" | ") : "never";
23028
+ const routeModulePatternType = routeModulePatternLiterals.length ? routeModulePatternLiterals.join(" | ") : "never";
23020
23029
  const routeTypesImportPath = `./${path14.basename(outPath).replace(/\.d\.ts$/, "")}`;
23021
- const augmentationBlock = suppressLintOnLink ? "" : `
23030
+ const linkAugmentationBlock = suppressLintOnLink ? "" : `
23022
23031
  declare module "@farm.js/core/client" {
23023
23032
  interface LinkDefaultRoute {
23024
23033
  _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
@@ -23042,14 +23051,25 @@ declare module "@farm.js/core/dist/client.js" {
23042
23051
  pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
23043
23052
  }
23044
23053
  }
23054
+ `;
23055
+ const routeModuleAugmentationBlock = `
23056
+ declare global {
23057
+ namespace FarmJS {
23058
+ interface RouteRegistry {
23059
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RouteModulePattern;
23060
+ }
23061
+ }
23062
+ }
23045
23063
  `;
23046
23064
  const content = `/**
23047
23065
  * Auto-generated route types from src/app.
23048
- * Link href is typed automatically via module augmentation. Regenerated on dev start and when routes change.
23066
+ * Link href and route component props are typed automatically from generated declarations.
23067
+ * Regenerated on dev start and when routes change.
23049
23068
  * Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
23050
23069
  */
23051
23070
  export type RoutePath = ${routePathType};
23052
- export type RoutePattern = ${routePatternType};${augmentationBlock}
23071
+ export type RoutePattern = ${routePatternType};
23072
+ export type RouteModulePattern = ${routeModulePatternType};${linkAugmentationBlock}${routeModuleAugmentationBlock}
23053
23073
  `;
23054
23074
  return content;
23055
23075
  }
@@ -23798,7 +23818,7 @@ function transformError(id, message) {
23798
23818
  __name(transformError, "transformError");
23799
23819
 
23800
23820
  // package.json
23801
- var version = "0.1.0-beta.13";
23821
+ var version = "0.1.0-beta.14";
23802
23822
 
23803
23823
  // src/version.ts
23804
23824
  var FARM_VERSION = version;