@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/index.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-VCANOYFI.mjs";
10
10
  import {
11
11
  build
12
- } from "./chunk-VSDZEB5M.mjs";
12
+ } from "./chunk-VUL55IAX.mjs";
13
13
  import "./chunk-4S3ORGFA.mjs";
14
14
  import "./chunk-SL6HTIOK.mjs";
15
15
  import {
@@ -148,7 +148,7 @@ import {
148
148
  parseRouteRenderingDirective,
149
149
  resolveRouteRenderingConfig,
150
150
  resolveRouteRenderingConfigFromFile
151
- } from "./chunk-Z3YG4OZT.mjs";
151
+ } from "./chunk-PNFQQSRA.mjs";
152
152
  import {
153
153
  APITypeGenerator
154
154
  } from "./chunk-LGHEOHBU.mjs";
@@ -394,7 +394,7 @@ import {
394
394
  getCurrentRequest
395
395
  } from "./chunk-RHIFZZUI.mjs";
396
396
  import "./chunk-LM2YNO4U.mjs";
397
- import "./chunk-3WIRO3N7.mjs";
397
+ import "./chunk-ARCGE2VT.mjs";
398
398
  import {
399
399
  SPARouter,
400
400
  getRouter,
@@ -16362,39 +16362,48 @@ async function createRouteTypeDeclarations(options, outPath) {
16362
16362
  const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
16363
16363
  const sourceRoots = options.sourceRoots ?? [{ name: "project", root, srcDir, layer: false }];
16364
16364
  const patterns = /* @__PURE__ */ new Set();
16365
+ const routeModulePatterns = /* @__PURE__ */ new Set();
16365
16366
  const glob = await import("fast-glob");
16366
16367
  for (const source of sourceRoots) {
16367
16368
  const appDir = path20.join(source.root, source.srcDir, "app");
16368
16369
  if (fs5.existsSync(appDir)) {
16369
- const pageFiles = await glob.default("**/page.{ts,tsx,js,jsx,md,mdx}", {
16370
- cwd: appDir,
16371
- absolute: false
16372
- });
16373
- for (const file of pageFiles) {
16370
+ const routeModuleFiles = await glob.default(
16371
+ "**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
16372
+ {
16373
+ cwd: appDir,
16374
+ absolute: false
16375
+ }
16376
+ );
16377
+ for (const file of routeModuleFiles) {
16374
16378
  if (parseRouteSlotFile(file)) continue;
16375
16379
  const route = parseRoutePath(file);
16380
+ const pattern = createRoutePattern(route);
16381
+ routeModulePatterns.add(pattern);
16376
16382
  if (route.type === "page") {
16377
- const pattern = createRoutePattern(route);
16378
16383
  patterns.add(pattern);
16379
16384
  }
16380
16385
  }
16381
16386
  }
16382
16387
  for (const route of await discoverProgrammaticRoutePaths(source.root, source.srcDir)) {
16383
16388
  patterns.add(route);
16389
+ routeModulePatterns.add(route);
16384
16390
  }
16385
16391
  }
16386
16392
  for (const route of extraRoutes) {
16387
16393
  if (route.startsWith("/")) {
16388
16394
  patterns.add(route);
16395
+ routeModulePatterns.add(route);
16389
16396
  }
16390
16397
  }
16391
16398
  const sortedPatterns = Array.from(patterns).sort();
16392
16399
  const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
16393
16400
  const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
16401
+ const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
16394
16402
  const routePathType = suppressLintOnLink ? "string" : typeLiterals.length ? typeLiterals.join(" | ") : "never";
16395
16403
  const routePatternType = suppressLintOnLink ? "string" : patternLiterals.length ? patternLiterals.join(" | ") : "never";
16404
+ const routeModulePatternType = routeModulePatternLiterals.length ? routeModulePatternLiterals.join(" | ") : "never";
16396
16405
  const routeTypesImportPath = `./${path20.basename(outPath).replace(/\.d\.ts$/, "")}`;
16397
- const augmentationBlock = suppressLintOnLink ? "" : `
16406
+ const linkAugmentationBlock = suppressLintOnLink ? "" : `
16398
16407
  declare module "@farm.js/core/client" {
16399
16408
  interface LinkDefaultRoute {
16400
16409
  _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
@@ -16418,14 +16427,25 @@ declare module "@farm.js/core/dist/client.js" {
16418
16427
  pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
16419
16428
  }
16420
16429
  }
16430
+ `;
16431
+ const routeModuleAugmentationBlock = `
16432
+ declare global {
16433
+ namespace FarmJS {
16434
+ interface RouteRegistry {
16435
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RouteModulePattern;
16436
+ }
16437
+ }
16438
+ }
16421
16439
  `;
16422
16440
  const content = `/**
16423
16441
  * Auto-generated route types from src/app.
16424
- * Link href is typed automatically via module augmentation. Regenerated on dev start and when routes change.
16442
+ * Link href and route component props are typed automatically from generated declarations.
16443
+ * Regenerated on dev start and when routes change.
16425
16444
  * Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
16426
16445
  */
16427
16446
  export type RoutePath = ${routePathType};
16428
- export type RoutePattern = ${routePatternType};${augmentationBlock}
16447
+ export type RoutePattern = ${routePatternType};
16448
+ export type RouteModulePattern = ${routeModulePatternType};${linkAugmentationBlock}${routeModuleAugmentationBlock}
16429
16449
  `;
16430
16450
  return content;
16431
16451
  }
@@ -16875,7 +16895,7 @@ var init_type_artifacts = __esm({
16875
16895
  var version;
16876
16896
  var init_package = __esm({
16877
16897
  "package.json"() {
16878
- version = "0.1.0-beta.13";
16898
+ version = "0.1.0-beta.14";
16879
16899
  }
16880
16900
  });
16881
16901