@farm.js/core 0.1.0-beta.5 → 0.1.0-beta.7

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 (149) hide show
  1. package/dist/agent-runtime.d.mts +2 -2
  2. package/dist/agent-runtime.d.ts +2 -2
  3. package/dist/api/route-manager.d.mts +3 -3
  4. package/dist/api/route-manager.d.ts +3 -3
  5. package/dist/api.d.mts +3 -3
  6. package/dist/api.d.ts +3 -3
  7. package/dist/{app-CakAr8Be.d.mts → app-BWtqQu3R.d.mts} +6 -4
  8. package/dist/app-markdown.cjs +31 -7
  9. package/dist/app-markdown.cjs.map +1 -1
  10. package/dist/app-markdown.d.mts +2 -2
  11. package/dist/app-markdown.d.ts +2 -2
  12. package/dist/app-markdown.mjs +2 -1
  13. package/dist/{app-BjN-da13.d.ts → app-xltejvLY.d.ts} +6 -4
  14. package/dist/{chunk-A2LUXHD2.mjs → chunk-5VYHFKWE.mjs} +214 -58
  15. package/dist/chunk-5VYHFKWE.mjs.map +1 -0
  16. package/dist/{chunk-EEABSBKK.mjs → chunk-6F5OI5GA.mjs} +2 -2
  17. package/dist/chunk-6F5OI5GA.mjs.map +1 -0
  18. package/dist/{chunk-LLC7BNXW.mjs → chunk-7FBJLMQH.mjs} +73 -10
  19. package/dist/chunk-7FBJLMQH.mjs.map +1 -0
  20. package/dist/{chunk-NM3CRAAL.mjs → chunk-B4W3BNTL.mjs} +24 -8
  21. package/dist/chunk-B4W3BNTL.mjs.map +1 -0
  22. package/dist/{chunk-BHG3LVHH.mjs → chunk-CGIXMLSY.mjs} +15 -7
  23. package/dist/chunk-CGIXMLSY.mjs.map +1 -0
  24. package/dist/{chunk-C3DLZMBU.mjs → chunk-DJSGLHCN.mjs} +2 -2
  25. package/dist/{chunk-2NHCNRF6.mjs → chunk-GFMBXLGP.mjs} +56 -20
  26. package/dist/chunk-GFMBXLGP.mjs.map +1 -0
  27. package/dist/chunk-I4CUBGVF.mjs +93 -0
  28. package/dist/chunk-I4CUBGVF.mjs.map +1 -0
  29. package/dist/{chunk-HNIQFZKB.mjs → chunk-ME4MO2RJ.mjs} +27 -37
  30. package/dist/chunk-ME4MO2RJ.mjs.map +1 -0
  31. package/dist/{chunk-RSKVYESE.mjs → chunk-RQ633A5I.mjs} +1 -1
  32. package/dist/chunk-RQ633A5I.mjs.map +1 -0
  33. package/dist/{chunk-2CUKEMVR.mjs → chunk-WDU6QXNK.mjs} +1 -1
  34. package/dist/chunk-WDU6QXNK.mjs.map +1 -0
  35. package/dist/{chunk-QGQX7SFC.mjs → chunk-ZVWA4ZQ3.mjs} +17 -8
  36. package/dist/chunk-ZVWA4ZQ3.mjs.map +1 -0
  37. package/dist/{client-plugins-DQQ1adXM.d.mts → client-plugins-BI2R6Eae.d.mts} +74 -3
  38. package/dist/{client-plugins-Cw4qUGsw.d.ts → client-plugins-DU9oMspX.d.ts} +74 -3
  39. package/dist/client-plugins.d.mts +2 -2
  40. package/dist/client-plugins.d.ts +2 -2
  41. package/dist/client.cjs.map +1 -1
  42. package/dist/client.d.mts +2 -2
  43. package/dist/client.d.ts +2 -2
  44. package/dist/client.mjs +1 -1
  45. package/dist/config.d.mts +2 -2
  46. package/dist/config.d.ts +2 -2
  47. package/dist/{devtools-LVC3VB5P.mjs → devtools-REQTS3I7.mjs} +6 -5
  48. package/dist/{devtools-LVC3VB5P.mjs.map → devtools-REQTS3I7.mjs.map} +1 -1
  49. package/dist/docs.cjs +51 -56
  50. package/dist/docs.cjs.map +1 -1
  51. package/dist/docs.mjs +6 -5
  52. package/dist/env-types.cjs +14 -5
  53. package/dist/env-types.cjs.map +1 -1
  54. package/dist/env-types.d.mts +2 -1
  55. package/dist/env-types.d.ts +2 -1
  56. package/dist/env-types.mjs +3 -1
  57. package/dist/env.cjs.map +1 -1
  58. package/dist/env.d.mts +1 -1
  59. package/dist/env.d.ts +1 -1
  60. package/dist/env.mjs +1 -1
  61. package/dist/i18n/client.d.mts +2 -2
  62. package/dist/i18n/client.d.ts +2 -2
  63. package/dist/i18n/index.d.mts +3 -3
  64. package/dist/i18n/index.d.ts +3 -3
  65. package/dist/i18n/server.d.mts +5 -5
  66. package/dist/i18n/server.d.ts +5 -5
  67. package/dist/index.cjs +931 -567
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.mts +15 -13
  70. package/dist/index.d.ts +15 -13
  71. package/dist/index.mjs +23 -16
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/integrations.d.mts +2 -2
  74. package/dist/integrations.d.ts +2 -2
  75. package/dist/internal/build-runtime.cjs +643 -322
  76. package/dist/internal/build-runtime.cjs.map +1 -1
  77. package/dist/internal/build-runtime.d.mts +4 -4
  78. package/dist/internal/build-runtime.d.ts +4 -4
  79. package/dist/internal/build-runtime.mjs +11 -10
  80. package/dist/internal/config-runtime.cjs +135 -39
  81. package/dist/internal/config-runtime.cjs.map +1 -1
  82. package/dist/internal/config-runtime.d.mts +3 -3
  83. package/dist/internal/config-runtime.d.ts +3 -3
  84. package/dist/internal/config-runtime.mjs +5 -4
  85. package/dist/internal/production-runtime.d.mts +6 -6
  86. package/dist/internal/production-runtime.d.ts +6 -6
  87. package/dist/markdown.cjs +73 -8
  88. package/dist/markdown.cjs.map +1 -1
  89. package/dist/markdown.d.mts +19 -2
  90. package/dist/markdown.d.ts +19 -2
  91. package/dist/markdown.mjs +5 -1
  92. package/dist/{metadata-BAPg_Nmo.d.ts → metadata-Cm9ujH4I.d.ts} +1 -1
  93. package/dist/{metadata-_6i9oFG3.d.mts → metadata-DacXbnLA.d.mts} +1 -1
  94. package/dist/middleware.d.mts +4 -4
  95. package/dist/middleware.d.ts +4 -4
  96. package/dist/plugin.cjs +679 -434
  97. package/dist/plugin.cjs.map +1 -1
  98. package/dist/plugin.d.mts +2 -2
  99. package/dist/plugin.d.ts +2 -2
  100. package/dist/plugin.mjs +8 -7
  101. package/dist/{production-runtime-DPfgMV9Y.d.mts → production-runtime-4KKq1AVC.d.mts} +2 -2
  102. package/dist/{production-runtime-BoJDc5mc.d.ts → production-runtime-DRsWDN2x.d.ts} +2 -2
  103. package/dist/{request-BrFBuc8G.d.mts → request-Dsq4kGW0.d.mts} +1 -1
  104. package/dist/{request-BslSZIRz.d.ts → request-udtobOLv.d.ts} +1 -1
  105. package/dist/request.d.mts +2 -2
  106. package/dist/request.d.ts +2 -2
  107. package/dist/{resolver-DlOPpjkB.d.mts → resolver-DJqjLMg_.d.mts} +1 -1
  108. package/dist/{resolver-C6iecsDV.d.ts → resolver-IH4RmPEl.d.ts} +1 -1
  109. package/dist/routes.d.mts +2 -2
  110. package/dist/routes.d.ts +2 -2
  111. package/dist/{runtime-DeAAZ6gO.d.mts → runtime-Cxpq6xZN.d.mts} +2 -2
  112. package/dist/{runtime-B6GvwDS1.d.ts → runtime-bv63eUiO.d.ts} +2 -2
  113. package/dist/server-plugins.d.mts +3 -3
  114. package/dist/server-plugins.d.ts +3 -3
  115. package/dist/server.cjs +731 -447
  116. package/dist/server.cjs.map +1 -1
  117. package/dist/server.d.mts +9 -9
  118. package/dist/server.d.ts +9 -9
  119. package/dist/server.mjs +9 -8
  120. package/dist/server.mjs.map +1 -1
  121. package/dist/testing.d.mts +2 -2
  122. package/dist/testing.d.ts +2 -2
  123. package/dist/{types-BH1lhg5G.d.mts → types-BMxWr97v.d.mts} +2 -2
  124. package/dist/{types-BH1lhg5G.d.ts → types-BMxWr97v.d.ts} +2 -2
  125. package/dist/{utils-Drsyz1Vj.d.ts → utils-B-cUHwoK.d.ts} +1 -1
  126. package/dist/{utils-CHXlMDkg.d.mts → utils-Cm41AefV.d.mts} +1 -1
  127. package/dist/version.cjs +1 -1
  128. package/dist/version.cjs.map +1 -1
  129. package/dist/version.mjs +1 -1
  130. package/dist/vite.cjs +682 -437
  131. package/dist/vite.cjs.map +1 -1
  132. package/dist/vite.d.mts +2 -2
  133. package/dist/vite.d.ts +2 -2
  134. package/dist/vite.mjs +6 -5
  135. package/package.json +3 -2
  136. package/types/client.d.ts +1 -1
  137. package/types/image.d.ts +4 -0
  138. package/types/images.d.ts +59 -0
  139. package/dist/chunk-2CUKEMVR.mjs.map +0 -1
  140. package/dist/chunk-2NHCNRF6.mjs.map +0 -1
  141. package/dist/chunk-A2LUXHD2.mjs.map +0 -1
  142. package/dist/chunk-BHG3LVHH.mjs.map +0 -1
  143. package/dist/chunk-EEABSBKK.mjs.map +0 -1
  144. package/dist/chunk-HNIQFZKB.mjs.map +0 -1
  145. package/dist/chunk-LLC7BNXW.mjs.map +0 -1
  146. package/dist/chunk-NM3CRAAL.mjs.map +0 -1
  147. package/dist/chunk-QGQX7SFC.mjs.map +0 -1
  148. package/dist/chunk-RSKVYESE.mjs.map +0 -1
  149. /package/dist/{chunk-C3DLZMBU.mjs.map → chunk-DJSGLHCN.mjs.map} +0 -0
@@ -13,8 +13,9 @@ import {
13
13
  createFarmImageHandler
14
14
  } from "./chunk-3XNTL3FQ.mjs";
15
15
  import {
16
+ createEnvTypeDeclarations,
16
17
  generateEnvTypes
17
- } from "./chunk-BHG3LVHH.mjs";
18
+ } from "./chunk-CGIXMLSY.mjs";
18
19
  import {
19
20
  writeFileIfChanged
20
21
  } from "./chunk-USWZZUEH.mjs";
@@ -23,6 +24,9 @@ import {
23
24
  isFarmNotFoundError,
24
25
  isFarmRedirectError
25
26
  } from "./chunk-7HO6AEOP.mjs";
27
+ import {
28
+ resolveFarmAuthConfig
29
+ } from "./chunk-I4CUBGVF.mjs";
26
30
  import {
27
31
  getFarmAppDirectories,
28
32
  getFarmLayerAliases,
@@ -43,17 +47,18 @@ import {
43
47
  import {
44
48
  resolveServerActionsConfig
45
49
  } from "./chunk-UB5UOSHB.mjs";
46
- import {
47
- createMarkdownMirrorResponse,
48
- resolveMarkdownConfig
49
- } from "./chunk-LLC7BNXW.mjs";
50
50
  import {
51
51
  createFarmMarkdownRouteModuleFromFile,
52
52
  createFarmMarkdownSourceResponse,
53
53
  isFarmMarkdownPageFile,
54
54
  loadFarmMdxComponents,
55
55
  resolveMdxConfig
56
- } from "./chunk-QGQX7SFC.mjs";
56
+ } from "./chunk-ZVWA4ZQ3.mjs";
57
+ import {
58
+ createMarkdownMirrorResponse,
59
+ resolveMarkdownConfig,
60
+ resolveMarkdownMirrorTarget
61
+ } from "./chunk-7FBJLMQH.mjs";
57
62
  import {
58
63
  resolveWorkflowsConfig
59
64
  } from "./chunk-XIVV5IWN.mjs";
@@ -142,7 +147,7 @@ import {
142
147
  } from "./chunk-RHIFZZUI.mjs";
143
148
  import {
144
149
  FARM_VERSION
145
- } from "./chunk-EEABSBKK.mjs";
150
+ } from "./chunk-6F5OI5GA.mjs";
146
151
  import {
147
152
  FARM_DEPLOYMENT_ID_HEADER,
148
153
  createFarmDeploymentCookie,
@@ -1206,8 +1211,56 @@ var _RouteManager = class _RouteManager {
1206
1211
  "**/{opengraph-image,twitter-image}.{ts,tsx,js,jsx,png,jpg,jpeg,gif,webp}",
1207
1212
  appDir
1208
1213
  );
1214
+ const canonicalPageGroups = /* @__PURE__ */ new Map();
1215
+ for (const file of pageFiles.filter((candidate) => parseRouteSlotFile(candidate) === null)) {
1216
+ const route = parseRoutePath(file);
1217
+ const pattern = this.createRoutePattern(route);
1218
+ const group = canonicalPageGroups.get(pattern);
1219
+ if (group) {
1220
+ group.files.push(file);
1221
+ } else {
1222
+ canonicalPageGroups.set(pattern, {
1223
+ route,
1224
+ files: [file]
1225
+ });
1226
+ }
1227
+ }
1228
+ for (const [pattern, group] of canonicalPageGroups) {
1229
+ const componentFiles = group.files.filter((file) => !isFarmMarkdownPageFile(file));
1230
+ const markdownFiles = group.files.filter(isFarmMarkdownPageFile);
1231
+ if (componentFiles.length > 1) {
1232
+ throw new Error(
1233
+ `Duplicate page route "${pattern}". Found ${componentFiles.map((file) => path3.join(appDir, file)).join(" and ")}.`
1234
+ );
1235
+ }
1236
+ if (markdownFiles.length > 1) {
1237
+ throw new Error(
1238
+ `Duplicate markdown representation for page route "${pattern}". Found ${markdownFiles.map((file) => path3.join(appDir, file)).join(" and ")}.`
1239
+ );
1240
+ }
1241
+ const componentFile = componentFiles[0];
1242
+ const markdownFile = markdownFiles[0];
1243
+ const primaryFile = componentFile || markdownFile;
1244
+ if (!primaryFile) continue;
1245
+ const modulePath = path3.join(appDir, primaryFile);
1246
+ const existing = this.routes.get(pattern);
1247
+ if (existing?.sourceRoot === source.root) {
1248
+ throw new Error(
1249
+ `Duplicate page route "${pattern}". Found both ${existing.modulePath} and ${modulePath}.`
1250
+ );
1251
+ }
1252
+ this.routes.set(pattern, {
1253
+ route: group.route,
1254
+ modulePath,
1255
+ ...markdownFile ? {
1256
+ markdownSourcePath: path3.join(appDir, markdownFile)
1257
+ } : {},
1258
+ pattern,
1259
+ source: "file",
1260
+ sourceRoot: source.root
1261
+ });
1262
+ }
1209
1263
  for (const [kind, files, target] of [
1210
- ["page", pageFiles.filter((file) => parseRouteSlotFile(file) === null), this.routes],
1211
1264
  ["layout", layoutFiles, this.layouts],
1212
1265
  ["loading", loadingFiles, this.loadings],
1213
1266
  ["error", errorFiles, this.errors]
@@ -2490,6 +2543,15 @@ var _ServerRenderer = class _ServerRenderer {
2490
2543
  });
2491
2544
  });
2492
2545
  } catch (error) {
2546
+ if (isWebResponse(error)) {
2547
+ if (!res.headersSent && !res.writableEnded) {
2548
+ await sendWebResponse(res, error);
2549
+ } else if (!res.writableEnded) {
2550
+ res.end();
2551
+ }
2552
+ completeRender(error.status, pathname);
2553
+ return;
2554
+ }
2493
2555
  if (isFarmRedirectError(error)) {
2494
2556
  const redirect = getFarmRedirectError(error);
2495
2557
  const snapshot = getFarmI18nClientSnapshot();
@@ -2790,7 +2852,7 @@ var _ServerRenderer = class _ServerRenderer {
2790
2852
  }
2791
2853
  }
2792
2854
  async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
2793
- return new Promise((resolve4, reject) => {
2855
+ return new Promise((resolve5, reject) => {
2794
2856
  const streamStartTime = Date.now();
2795
2857
  const observabilityRoute = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
2796
2858
  const deploymentId = this.getDeploymentId();
@@ -2970,7 +3032,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
2970
3032
  route: observabilityRoute,
2971
3033
  durationMs: Date.now() - streamStartTime
2972
3034
  });
2973
- resolve4();
3035
+ resolve5();
2974
3036
  }
2975
3037
  });
2976
3038
  res.write(shell);
@@ -2981,7 +3043,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
2981
3043
  },
2982
3044
  onShellError(error) {
2983
3045
  didError = true;
2984
- if (!isFarmRedirectError(error) && !isFarmNotFoundError(error)) {
3046
+ if (!isWebResponse(error) && !isFarmRedirectError(error) && !isFarmNotFoundError(error)) {
2985
3047
  logger.error(`SSR shell error: ${error}`);
2986
3048
  emitFarmEvent({
2987
3049
  type: "render.error",
@@ -2996,7 +3058,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
2996
3058
  },
2997
3059
  onError(error) {
2998
3060
  didError = true;
2999
- if (!isFarmRedirectError(error) && !isFarmNotFoundError(error)) {
3061
+ if (!isWebResponse(error) && !isFarmRedirectError(error) && !isFarmNotFoundError(error)) {
3000
3062
  logger.error(`SSR streaming error: ${error}`);
3001
3063
  emitFarmEvent({
3002
3064
  type: "render.error",
@@ -3209,6 +3271,7 @@ var _FarmApp = class _FarmApp {
3209
3271
  deploy: config.deploy || {},
3210
3272
  storage: config.storage || {},
3211
3273
  cache: config.cache || {},
3274
+ auth: isResolvedAuthConfig(config.auth) ? config.auth : resolveFarmAuthConfig(config.auth),
3212
3275
  integrations: config.integrations || {},
3213
3276
  plugins: config.plugins || [],
3214
3277
  migrations: config.migrations || { commands: [] },
@@ -3281,6 +3344,12 @@ function isResolvedI18nConfig(value) {
3281
3344
  return Boolean(value && typeof value === "object" && "enabled" in value);
3282
3345
  }
3283
3346
  __name(isResolvedI18nConfig, "isResolvedI18nConfig");
3347
+ function isResolvedAuthConfig(value) {
3348
+ return Boolean(
3349
+ value && typeof value === "object" && "enabled" in value && "emailAndPassword" in value && "database" in value
3350
+ );
3351
+ }
3352
+ __name(isResolvedAuthConfig, "isResolvedAuthConfig");
3284
3353
  function createFarmApp(config, viteServer) {
3285
3354
  return new FarmApp(config, viteServer);
3286
3355
  }
@@ -3616,8 +3685,8 @@ __name(_HMRManager, "HMRManager");
3616
3685
  var HMRManager = _HMRManager;
3617
3686
 
3618
3687
  // src/type-artifacts.ts
3619
- import { mkdirSync as mkdirSync4 } from "fs";
3620
- import { dirname as dirname3, join as join4, resolve as resolve2 } from "path";
3688
+ import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync2, unlinkSync } from "fs";
3689
+ import { dirname as dirname3, join as join4, resolve as resolve3 } from "path";
3621
3690
 
3622
3691
  // src/routing/generate-route-types.ts
3623
3692
  import * as path6 from "path";
@@ -3662,15 +3731,19 @@ function createRoutePattern(route) {
3662
3731
  __name(createRoutePattern, "createRoutePattern");
3663
3732
  var DEFAULT_OUT_FILE = "farm-routes.d.ts";
3664
3733
  async function generateRouteTypes(options) {
3665
- const {
3666
- root,
3667
- srcDir = "src",
3668
- outFile = DEFAULT_OUT_FILE,
3669
- extraRoutes = [],
3670
- suppressLintOnLink = false
3671
- } = options;
3734
+ const root = path6.resolve(options.root);
3735
+ const srcDir = options.srcDir || "src";
3736
+ const outFile = options.outFile || DEFAULT_OUT_FILE;
3737
+ const outPath = path6.isAbsolute(outFile) ? outFile : path6.join(root, srcDir, outFile);
3738
+ const content = await createRouteTypeDeclarations(options, outPath);
3739
+ fs3.mkdirSync(path6.dirname(outPath), { recursive: true });
3740
+ writeFileIfChanged(outPath, content);
3741
+ return outPath;
3742
+ }
3743
+ __name(generateRouteTypes, "generateRouteTypes");
3744
+ async function createRouteTypeDeclarations(options, outPath) {
3745
+ const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
3672
3746
  const sourceRoots = options.sourceRoots ?? [{ name: "project", root, srcDir, layer: false }];
3673
- const outPath = path6.join(root, srcDir, outFile);
3674
3747
  const patterns = /* @__PURE__ */ new Set();
3675
3748
  const glob = await import("fast-glob");
3676
3749
  for (const source of sourceRoots) {
@@ -3703,18 +3776,19 @@ async function generateRouteTypes(options) {
3703
3776
  const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
3704
3777
  const routePathType = suppressLintOnLink ? "string" : typeLiterals.length ? typeLiterals.join(" | ") : "never";
3705
3778
  const routePatternType = suppressLintOnLink ? "string" : patternLiterals.length ? patternLiterals.join(" | ") : "never";
3779
+ const routeTypesImportPath = `./${path6.basename(outPath).replace(/\.d\.ts$/, "")}`;
3706
3780
  const augmentationBlock = suppressLintOnLink ? "" : `
3707
3781
  declare module "@farm.js/core/client" {
3708
3782
  interface LinkDefaultRoute {
3709
- _: import("./farm-routes").RoutePath;
3710
- pattern: import("./farm-routes").RoutePattern;
3783
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
3784
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
3711
3785
  }
3712
3786
  }
3713
3787
 
3714
3788
  declare module "@farm.js/core" {
3715
3789
  interface LinkDefaultRoute {
3716
- _: import("./farm-routes").RoutePath;
3717
- pattern: import("./farm-routes").RoutePattern;
3790
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
3791
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
3718
3792
  }
3719
3793
  // Ensure root import ("@farm.js/core") uses the same typed Link signature as client entry.
3720
3794
  const Link: typeof import("@farm.js/core/client").Link;
@@ -3723,8 +3797,8 @@ declare module "@farm.js/core" {
3723
3797
  // Internal declaration path used by @farm.js/core root type re-exports.
3724
3798
  declare module "@farm.js/core/dist/client.js" {
3725
3799
  interface LinkDefaultRoute {
3726
- _: import("./farm-routes").RoutePath;
3727
- pattern: import("./farm-routes").RoutePattern;
3800
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
3801
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
3728
3802
  }
3729
3803
  }
3730
3804
  `;
@@ -3736,11 +3810,9 @@ declare module "@farm.js/core/dist/client.js" {
3736
3810
  export type RoutePath = ${routePathType};
3737
3811
  export type RoutePattern = ${routePatternType};${augmentationBlock}
3738
3812
  `;
3739
- fs3.mkdirSync(path6.dirname(outPath), { recursive: true });
3740
- writeFileIfChanged(outPath, content);
3741
- return outPath;
3813
+ return content;
3742
3814
  }
3743
- __name(generateRouteTypes, "generateRouteTypes");
3815
+ __name(createRouteTypeDeclarations, "createRouteTypeDeclarations");
3744
3816
 
3745
3817
  // src/image-types.ts
3746
3818
  import { mkdirSync as mkdirSync2 } from "fs";
@@ -3777,11 +3849,11 @@ __name(createFarmImageTypeDeclarations, "createFarmImageTypeDeclarations");
3777
3849
 
3778
3850
  // src/i18n/type-generator.ts
3779
3851
  import { mkdirSync as mkdirSync3 } from "fs";
3780
- import { dirname as dirname2, join as join3, resolve } from "path";
3852
+ import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
3781
3853
  async function generateFarmI18nTypes(options) {
3782
3854
  if (!options.config.enabled) return void 0;
3783
3855
  const { signatures } = await readFarmI18nCatalogs(options.config);
3784
- const outFile = options.outFile ? resolve(options.root, options.outFile) : join3(resolve(options.root), options.srcDir || "src", "farm-i18n.d.ts");
3856
+ const outFile = options.outFile ? resolve2(options.root, options.outFile) : join3(resolve2(options.root), options.srcDir || "src", "farm-i18n.d.ts");
3785
3857
  const content = renderFarmI18nTypes(options.config.locales, signatures);
3786
3858
  mkdirSync3(dirname2(outFile), { recursive: true });
3787
3859
  writeFileIfChanged(outFile, content);
@@ -3831,7 +3903,7 @@ __name(argumentType, "argumentType");
3831
3903
 
3832
3904
  // src/type-artifacts.ts
3833
3905
  async function generateFarmTypeArtifacts(options) {
3834
- const root = resolve2(options.root);
3906
+ const root = resolve3(options.root);
3835
3907
  const srcDir = options.srcDir || "src";
3836
3908
  const shouldGenerateRoutes = options.routes !== false;
3837
3909
  const shouldGenerateApi = options.api !== false;
@@ -3843,7 +3915,10 @@ async function generateFarmTypeArtifacts(options) {
3843
3915
  const result = {
3844
3916
  apiRoutes: []
3845
3917
  };
3846
- if (shouldGenerateRoutes) {
3918
+ const unifiedTypesPath = join4(root, srcDir, "farm.d.ts");
3919
+ const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
3920
+ const unifiedSections = [];
3921
+ if (shouldRefreshUnifiedTypes && !options.routeTypesOutFile) {
3847
3922
  const routeOptions = {
3848
3923
  root,
3849
3924
  srcDir,
@@ -3851,37 +3926,62 @@ async function generateFarmTypeArtifacts(options) {
3851
3926
  suppressLintOnLink: options.suppressLintOnLink,
3852
3927
  sourceRoots
3853
3928
  };
3854
- if (options.routeTypesOutFile) {
3855
- routeOptions.outFile = options.routeTypesOutFile;
3856
- }
3857
- result.routeTypesPath = await generateRouteTypes(routeOptions);
3929
+ unifiedSections.push(await createRouteTypeDeclarations(routeOptions, unifiedTypesPath));
3930
+ result.routeTypesPath = unifiedTypesPath;
3931
+ } else if (shouldGenerateRoutes) {
3932
+ result.routeTypesPath = await generateRouteTypes({
3933
+ root,
3934
+ srcDir,
3935
+ outFile: options.routeTypesOutFile,
3936
+ extraRoutes: options.extraRoutes || [],
3937
+ suppressLintOnLink: options.suppressLintOnLink,
3938
+ sourceRoots
3939
+ });
3858
3940
  }
3859
3941
  if (shouldGenerateApi) {
3860
3942
  const generator = new APITypeGenerator(appDirs);
3861
3943
  const apiRoutes = generator.scanAPIRoutes();
3862
- const apiTypesPath = options.apiTypesOutFile ? resolve2(root, options.apiTypesOutFile) : join4(root, srcDir, "lib", "api.generated.ts");
3944
+ const apiTypesPath = options.apiTypesOutFile ? resolve3(root, options.apiTypesOutFile) : join4(root, srcDir, "lib", "api.generated.ts");
3863
3945
  const content = generator.generateAPIRouter(apiRoutes, { outFile: apiTypesPath });
3864
3946
  mkdirSync4(dirname3(apiTypesPath), { recursive: true });
3865
3947
  writeFileIfChanged(apiTypesPath, content);
3866
3948
  result.apiTypesPath = apiTypesPath;
3867
3949
  result.apiRoutes = apiRoutes;
3868
3950
  }
3869
- if (shouldGenerateEnv) {
3951
+ if (shouldRefreshUnifiedTypes && !options.envTypesOutFile) {
3952
+ unifiedSections.push(
3953
+ createEnvTypeDeclarations(
3954
+ {
3955
+ root,
3956
+ srcDir,
3957
+ configPath: options.configPath,
3958
+ layerConfigPaths: (options.layers ?? []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
3959
+ },
3960
+ unifiedTypesPath
3961
+ )
3962
+ );
3963
+ result.envTypesPath = unifiedTypesPath;
3964
+ } else if (shouldGenerateEnv) {
3870
3965
  result.envTypesPath = await generateEnvTypes({
3871
3966
  root,
3872
3967
  srcDir,
3873
3968
  outFile: options.envTypesOutFile,
3969
+ configPath: options.configPath,
3874
3970
  layerConfigPaths: (options.layers ?? []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
3875
3971
  });
3876
3972
  }
3877
- if (shouldGenerateImages) {
3973
+ if (shouldGenerateImages && options.imageTypesOutFile) {
3878
3974
  result.imageTypesPath = generateFarmImageTypes({
3879
3975
  root,
3880
3976
  srcDir,
3881
3977
  outFile: options.imageTypesOutFile
3882
3978
  });
3883
3979
  }
3884
- if (shouldGenerateI18n && options.i18nConfig) {
3980
+ if (shouldRefreshUnifiedTypes && options.i18nConfig?.enabled && !options.i18nTypesOutFile) {
3981
+ const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
3982
+ unifiedSections.push(renderFarmI18nTypes(options.i18nConfig.locales, signatures));
3983
+ result.i18nTypesPath = unifiedTypesPath;
3984
+ } else if (shouldGenerateI18n && options.i18nConfig) {
3885
3985
  result.i18nTypesPath = await generateFarmI18nTypes({
3886
3986
  root,
3887
3987
  srcDir,
@@ -3889,9 +3989,42 @@ async function generateFarmTypeArtifacts(options) {
3889
3989
  outFile: options.i18nTypesOutFile
3890
3990
  });
3891
3991
  }
3992
+ if (shouldRefreshUnifiedTypes) {
3993
+ mkdirSync4(dirname3(unifiedTypesPath), { recursive: true });
3994
+ writeFileIfChanged(
3995
+ unifiedTypesPath,
3996
+ `/**
3997
+ * Generated by Farm.js. Do not edit.
3998
+ * Contains project-specific route, environment, and internationalization types.
3999
+ */
4000
+
4001
+ import "@farm.js/core/image";
4002
+
4003
+ ${unifiedSections.join("\n")}`
4004
+ );
4005
+ result.typesPath = unifiedTypesPath;
4006
+ removeLegacyTypeArtifacts(root, srcDir);
4007
+ }
3892
4008
  return result;
3893
4009
  }
3894
4010
  __name(generateFarmTypeArtifacts, "generateFarmTypeArtifacts");
4011
+ var LEGACY_TYPE_ARTIFACTS = [
4012
+ ["farm-routes.d.ts", "Auto-generated route types"],
4013
+ ["farm-env.d.ts", "Auto-generated env types"],
4014
+ ["farm-images.d.ts", "Generated by Farm.js"],
4015
+ ["farm-i18n.d.ts", "Generated by Farm.js"]
4016
+ ];
4017
+ function removeLegacyTypeArtifacts(root, srcDir) {
4018
+ for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
4019
+ const filePath = join4(root, srcDir, fileName);
4020
+ if (!existsSync3(filePath)) continue;
4021
+ const source = readFileSync2(filePath, "utf8");
4022
+ if (source.includes(marker)) {
4023
+ unlinkSync(filePath);
4024
+ }
4025
+ }
4026
+ }
4027
+ __name(removeLegacyTypeArtifacts, "removeLegacyTypeArtifacts");
3895
4028
 
3896
4029
  // src/vite.ts
3897
4030
  import * as fs4 from "fs";
@@ -3971,7 +4104,7 @@ var ALL_TYPE_ARTIFACTS = {
3971
4104
  routes: true,
3972
4105
  api: true,
3973
4106
  env: true,
3974
- images: true,
4107
+ images: false,
3975
4108
  i18n: true
3976
4109
  };
3977
4110
  var createEmptyTypeArtifactSelection = /* @__PURE__ */ __name(() => ({
@@ -4008,7 +4141,7 @@ function loadFarmWorkflowsDevRuntime() {
4008
4141
  }
4009
4142
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
4010
4143
  function loadFarmDevtoolsSnapshotRuntime() {
4011
- return import("./devtools-LVC3VB5P.mjs");
4144
+ return import("./devtools-REQTS3I7.mjs");
4012
4145
  }
4013
4146
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
4014
4147
  function loadFarmDevtoolsUIRuntime() {
@@ -4756,12 +4889,13 @@ function farmPlugin(options = {}, initialPluginManager) {
4756
4889
  config: farmApp.getConfig().mdx,
4757
4890
  resolveSource: /* @__PURE__ */ __name(async (pathname2) => {
4758
4891
  const match = farmApp.getRouteManager().matchRoute(pathname2);
4759
- if (!match.route || !isFarmMarkdownPageFile(match.route.modulePath)) {
4892
+ const sourcePath = match.route?.markdownSourcePath || (match.route && isFarmMarkdownPageFile(match.route.modulePath) ? match.route.modulePath : null);
4893
+ if (!sourcePath) {
4760
4894
  return null;
4761
4895
  }
4762
4896
  return {
4763
- source: await fs4.promises.readFile(match.route.modulePath, "utf8"),
4764
- filePath: match.route.modulePath
4897
+ source: await fs4.promises.readFile(sourcePath, "utf8"),
4898
+ filePath: sourcePath
4765
4899
  };
4766
4900
  }, "resolveSource")
4767
4901
  });
@@ -4782,16 +4916,37 @@ function farmPlugin(options = {}, initialPluginManager) {
4782
4916
  await sendWebResponse(res, markdownResponse);
4783
4917
  return;
4784
4918
  }
4919
+ const markdownPageTarget = resolveMarkdownMirrorTarget(
4920
+ farmApp.getConfig().md,
4921
+ requestPathname,
4922
+ {
4923
+ accept: "text/markdown"
4924
+ }
4925
+ );
4926
+ if (markdownPageTarget && farmApp.getRouteManager().matchRoute(markdownPageTarget.pathname).route) {
4927
+ const vary = res.getHeader("Vary");
4928
+ const varyValues = String(vary || "").split(",").map((value) => value.trim()).filter(Boolean);
4929
+ if (!varyValues.some((value) => value.toLowerCase() === "accept")) {
4930
+ res.setHeader("Vary", [...varyValues, "Accept"].join(", "));
4931
+ }
4932
+ const alternatePath = markdownPageTarget.pathname === "/" ? "/index.md" : `${markdownPageTarget.pathname}.md`;
4933
+ const alternateLink = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
4934
+ const currentLink = res.getHeader("Link");
4935
+ res.setHeader(
4936
+ "Link",
4937
+ currentLink ? `${String(currentLink)}, ${alternateLink}` : alternateLink
4938
+ );
4939
+ }
4785
4940
  if (workflowHandler && (requestPathname === workflowConfig.route || requestPathname.startsWith(`${workflowConfig.route}/`))) {
4786
4941
  let workflowBody;
4787
4942
  if (requestMethod !== "GET" && requestMethod !== "HEAD") {
4788
- workflowBody = await new Promise((resolve4) => {
4943
+ workflowBody = await new Promise((resolve5) => {
4789
4944
  let data = "";
4790
4945
  req.on("data", (chunk) => {
4791
4946
  data += chunk;
4792
4947
  });
4793
4948
  req.on("end", () => {
4794
- resolve4(data);
4949
+ resolve5(data);
4795
4950
  });
4796
4951
  });
4797
4952
  }
@@ -4834,13 +4989,13 @@ function farmPlugin(options = {}, initialPluginManager) {
4834
4989
  }
4835
4990
  let body;
4836
4991
  if (req.method !== "GET" && req.method !== "HEAD") {
4837
- body = await new Promise((resolve4) => {
4992
+ body = await new Promise((resolve5) => {
4838
4993
  let data = "";
4839
4994
  req.on("data", (chunk) => {
4840
4995
  data += chunk;
4841
4996
  });
4842
4997
  req.on("end", () => {
4843
- resolve4(data);
4998
+ resolve5(data);
4844
4999
  });
4845
5000
  });
4846
5001
  }
@@ -4946,13 +5101,13 @@ function farmPlugin(options = {}, initialPluginManager) {
4946
5101
  }
4947
5102
  let body;
4948
5103
  if (req.method !== "GET" && req.method !== "HEAD") {
4949
- body = await new Promise((resolve4) => {
5104
+ body = await new Promise((resolve5) => {
4950
5105
  let data = "";
4951
5106
  req.on("data", (chunk) => {
4952
5107
  data += chunk;
4953
5108
  });
4954
5109
  req.on("end", () => {
4955
- resolve4(data);
5110
+ resolve5(data);
4956
5111
  });
4957
5112
  });
4958
5113
  }
@@ -5009,13 +5164,13 @@ function farmPlugin(options = {}, initialPluginManager) {
5009
5164
  }
5010
5165
  let body;
5011
5166
  if (req.method !== "GET" && req.method !== "HEAD") {
5012
- body = await new Promise((resolve4) => {
5167
+ body = await new Promise((resolve5) => {
5013
5168
  let data = "";
5014
5169
  req.on("data", (chunk) => {
5015
5170
  data += chunk;
5016
5171
  });
5017
5172
  req.on("end", () => {
5018
- resolve4(data);
5173
+ resolve5(data);
5019
5174
  });
5020
5175
  });
5021
5176
  }
@@ -6879,6 +7034,7 @@ async function buildRouteComponentProps(pageModule, params, searchParams, path,
6879
7034
  const parsedSearch = parseClientRouteSchema(schemas?.search, searchParams, 'search');
6880
7035
 
6881
7036
  return {
7037
+ ...(existingProps || {}),
6882
7038
  params: parsedParams,
6883
7039
  search: parsedSearch,
6884
7040
  searchParams: schemas ? Promise.resolve(parsedSearch) : parsedSearch,
@@ -7628,4 +7784,4 @@ export {
7628
7784
  farmPlugin,
7629
7785
  defineConfig
7630
7786
  };
7631
- //# sourceMappingURL=chunk-A2LUXHD2.mjs.map
7787
+ //# sourceMappingURL=chunk-5VYHFKWE.mjs.map