@farm.js/core 0.1.17 → 0.1.18

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 (249) hide show
  1. package/dist/after.cjs +12 -225
  2. package/dist/agent-runtime.cjs +83 -2800
  3. package/dist/api/client.cjs +17 -4060
  4. package/dist/api/route-manager.cjs +34 -4354
  5. package/dist/api/runtime.cjs +29 -2696
  6. package/dist/api.cjs +88 -8434
  7. package/dist/app-markdown.cjs +39 -280
  8. package/dist/cache.cjs +38 -1560
  9. package/dist/chunk-22GUSVNJ.cjs +351 -0
  10. package/dist/chunk-2CQ74SP6.cjs +13 -0
  11. package/dist/chunk-2SJ4RQ6P.cjs +57 -0
  12. package/dist/chunk-3376ZTRC.cjs +1 -0
  13. package/dist/{chunk-YD4J4XCI.mjs → chunk-3XG26Z3J.mjs} +1 -1
  14. package/dist/chunk-4PNUXIVU.cjs +472 -0
  15. package/dist/chunk-4PPEPOZZ.cjs +21 -0
  16. package/dist/chunk-4ZFL5GFN.cjs +520 -0
  17. package/dist/chunk-5OVTOKGH.cjs +65 -0
  18. package/dist/chunk-5QIKR7RR.cjs +224 -0
  19. package/dist/chunk-5ZSWG4UX.cjs +127 -0
  20. package/dist/chunk-62YJ2IEB.cjs +238 -0
  21. package/dist/chunk-6EODJYCX.cjs +183 -0
  22. package/dist/chunk-6EXBPJ24.cjs +434 -0
  23. package/dist/chunk-6QQDAAAZ.cjs +38 -0
  24. package/dist/chunk-6V4TDWEC.cjs +455 -0
  25. package/dist/chunk-72ADZ6GQ.cjs +19 -0
  26. package/dist/chunk-75BRBIFP.cjs +172 -0
  27. package/dist/chunk-7W3CPVXS.cjs +24 -0
  28. package/dist/chunk-A6WIQH5Z.cjs +31 -0
  29. package/dist/chunk-AFOD3LYZ.cjs +377 -0
  30. package/dist/chunk-AMDMVWMI.cjs +39 -0
  31. package/dist/chunk-AORPIPNB.cjs +552 -0
  32. package/dist/chunk-ARJWXNQL.cjs +256 -0
  33. package/dist/chunk-AWRISO2H.cjs +2199 -0
  34. package/dist/chunk-AYJR42WX.cjs +711 -0
  35. package/dist/chunk-B4CH33IG.cjs +644 -0
  36. package/dist/chunk-BIDYX3SL.cjs +91 -0
  37. package/dist/chunk-BSTRERPP.cjs +40 -0
  38. package/dist/chunk-BYODCJD6.cjs +663 -0
  39. package/dist/chunk-C3VRMB6H.cjs +85 -0
  40. package/dist/chunk-C5GUTBZK.cjs +173 -0
  41. package/dist/chunk-CIAGU2X4.cjs +337 -0
  42. package/dist/chunk-CMGMGHUZ.cjs +27 -0
  43. package/dist/chunk-CXP5U3RW.cjs +54 -0
  44. package/dist/chunk-D2ULAULS.cjs +166 -0
  45. package/dist/chunk-D7JTOLFK.cjs +285 -0
  46. package/dist/chunk-DVM4FKZL.cjs +169 -0
  47. package/dist/chunk-DYEJQTDN.cjs +49 -0
  48. package/dist/chunk-E2BMSZ2W.cjs +151 -0
  49. package/dist/chunk-E3UK5IIB.cjs +593 -0
  50. package/dist/chunk-EM6SBQKM.cjs +470 -0
  51. package/dist/chunk-FJSWYIR7.cjs +482 -0
  52. package/dist/chunk-FK6GO24V.cjs +54 -0
  53. package/dist/chunk-FXUUWYAX.cjs +654 -0
  54. package/dist/chunk-G3HRIVEY.cjs +395 -0
  55. package/dist/chunk-G643DQCH.cjs +13 -0
  56. package/dist/chunk-G7HXGLEC.cjs +175 -0
  57. package/dist/chunk-GDSHDTJ4.cjs +152 -0
  58. package/dist/chunk-GNEO2XOF.cjs +2040 -0
  59. package/dist/{chunk-56DAX2BE.mjs → chunk-GYKJCFTS.mjs} +1 -1
  60. package/dist/chunk-H6G5INWM.cjs +1094 -0
  61. package/dist/chunk-HBTUGXHS.cjs +180 -0
  62. package/dist/chunk-HREOKQWT.cjs +45 -0
  63. package/dist/chunk-I4J452B7.cjs +435 -0
  64. package/dist/chunk-I57LW5VZ.cjs +94 -0
  65. package/dist/chunk-I7PUUDGY.cjs +389 -0
  66. package/dist/chunk-IAMRBF3Z.cjs +86 -0
  67. package/dist/chunk-IKNRN4VS.cjs +14214 -0
  68. package/dist/chunk-IQXFRNY2.cjs +169 -0
  69. package/dist/chunk-IXTFU4PL.cjs +2355 -0
  70. package/dist/chunk-J2OP5GG3.cjs +725 -0
  71. package/dist/chunk-J3LOGE4T.cjs +42 -0
  72. package/dist/chunk-J7FSKED3.cjs +93 -0
  73. package/dist/chunk-JDNHKPTD.cjs +22 -0
  74. package/dist/chunk-JSROZYYO.cjs +164 -0
  75. package/dist/chunk-K6FNHVDR.cjs +696 -0
  76. package/dist/chunk-KGZIORNL.cjs +43 -0
  77. package/dist/{chunk-MVIWBEJF.mjs → chunk-KPNVGRBL.mjs} +1 -1
  78. package/dist/chunk-KR6CKSXT.cjs +15 -0
  79. package/dist/chunk-KROWKCUH.cjs +185 -0
  80. package/dist/chunk-KVFPGF2M.cjs +46 -0
  81. package/dist/chunk-LCCBO7PJ.cjs +46 -0
  82. package/dist/chunk-LIUGYUX3.cjs +22 -0
  83. package/dist/chunk-LTNGXMQ6.cjs +55 -0
  84. package/dist/chunk-M2L4MYDQ.cjs +14 -0
  85. package/dist/chunk-MCJLA63J.cjs +1 -0
  86. package/dist/chunk-MKB2EGIR.cjs +148 -0
  87. package/dist/chunk-MQ3H6LT5.cjs +202 -0
  88. package/dist/chunk-MT763TDW.cjs +43 -0
  89. package/dist/chunk-MWSK6C4J.cjs +18 -0
  90. package/dist/chunk-MWWVKDW3.cjs +169 -0
  91. package/dist/chunk-NO3WWW3N.cjs +192 -0
  92. package/dist/chunk-NV3A5DXM.cjs +862 -0
  93. package/dist/chunk-NWOD6NIT.cjs +9 -0
  94. package/dist/chunk-NZKJGRB3.cjs +230 -0
  95. package/dist/chunk-OAVTUMJP.cjs +1496 -0
  96. package/dist/chunk-OHY2ZWUG.cjs +25 -0
  97. package/dist/chunk-OI6CMLWX.cjs +47 -0
  98. package/dist/chunk-OIEOCXKG.cjs +453 -0
  99. package/dist/chunk-OWOUTKIJ.cjs +558 -0
  100. package/dist/chunk-OX6O6WVA.cjs +74 -0
  101. package/dist/chunk-OXSIH4D6.cjs +476 -0
  102. package/dist/chunk-OYEUREB6.cjs +35 -0
  103. package/dist/chunk-PCOTGFSM.cjs +139 -0
  104. package/dist/chunk-PZYCPSCC.cjs +35 -0
  105. package/dist/chunk-QBK2AA4U.cjs +445 -0
  106. package/dist/chunk-QBPXNZGV.cjs +487 -0
  107. package/dist/chunk-QNPEUFHQ.cjs +27 -0
  108. package/dist/chunk-QZRVZSPN.cjs +236 -0
  109. package/dist/chunk-R5A5KNVX.cjs +20 -0
  110. package/dist/chunk-R5JIFR6B.cjs +42 -0
  111. package/dist/chunk-R6AIILII.cjs +193 -0
  112. package/dist/chunk-RG3ZOTG5.cjs +34 -0
  113. package/dist/chunk-ROUTX2E5.cjs +390 -0
  114. package/dist/chunk-RTHIVJ2G.cjs +54 -0
  115. package/dist/chunk-S3A45T7F.cjs +166 -0
  116. package/dist/chunk-S3JO3N4H.cjs +17 -0
  117. package/dist/chunk-SK35NQKK.cjs +27 -0
  118. package/dist/chunk-SU7MH53P.cjs +180 -0
  119. package/dist/chunk-SVRTJOUF.cjs +113 -0
  120. package/dist/chunk-SWN467MP.cjs +18 -0
  121. package/dist/chunk-SYQ3MOWW.cjs +73 -0
  122. package/dist/chunk-T5CERMEH.cjs +417 -0
  123. package/dist/chunk-TFAXUHWX.cjs +206 -0
  124. package/dist/chunk-TIWHTW3Q.cjs +24 -0
  125. package/dist/chunk-TKJZFIML.cjs +20 -0
  126. package/dist/chunk-TKNSDBBN.cjs +193 -0
  127. package/dist/chunk-TWGMSEHX.cjs +525 -0
  128. package/dist/chunk-TYQUSXUG.cjs +1357 -0
  129. package/dist/chunk-U4KT7QP3.cjs +23 -0
  130. package/dist/chunk-UJ2C4ICS.cjs +277 -0
  131. package/dist/chunk-UN5GHC5V.cjs +10244 -0
  132. package/dist/chunk-UQZ4AYTH.cjs +168 -0
  133. package/dist/chunk-US2QVW3E.cjs +36 -0
  134. package/dist/chunk-VB6UCX3V.cjs +421 -0
  135. package/dist/chunk-VEKFLAQM.cjs +300 -0
  136. package/dist/chunk-VQDBNVOO.cjs +14 -0
  137. package/dist/chunk-W4E7WMXE.cjs +71 -0
  138. package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
  139. package/dist/chunk-WMAPPDMM.cjs +28 -0
  140. package/dist/chunk-WMOGFOUJ.cjs +223 -0
  141. package/dist/chunk-WPYFSQKK.cjs +37 -0
  142. package/dist/chunk-WZMNW2IW.cjs +1415 -0
  143. package/dist/chunk-XGC343EY.cjs +443 -0
  144. package/dist/chunk-XSKZORAS.cjs +727 -0
  145. package/dist/chunk-XWAWFQFS.cjs +82 -0
  146. package/dist/chunk-Y4YMF2NQ.cjs +460 -0
  147. package/dist/chunk-Y4YWHNKU.cjs +250 -0
  148. package/dist/chunk-Y53ZSFN6.cjs +504 -0
  149. package/dist/chunk-YA6LLTIJ.cjs +411 -0
  150. package/dist/chunk-YFPGHF5F.cjs +202 -0
  151. package/dist/chunk-YJRZR7VU.cjs +28 -0
  152. package/dist/chunk-YTAABQEV.cjs +1 -0
  153. package/dist/chunk-YX3DBN4M.cjs +18 -0
  154. package/dist/chunk-YZTASLPQ.cjs +64 -0
  155. package/dist/chunk-Z5HIWVDP.cjs +2173 -0
  156. package/dist/chunk-ZEG3OPIB.cjs +93 -0
  157. package/dist/chunk-ZMN3H73H.cjs +155 -0
  158. package/dist/client/lifecycle.cjs +6 -35
  159. package/dist/client-plugins.cjs +7 -448
  160. package/dist/client.cjs +171 -9808
  161. package/dist/config.cjs +8 -36
  162. package/dist/cron.cjs +24 -491
  163. package/dist/deferred.cjs +26 -475
  164. package/dist/deployment.cjs +39 -210
  165. package/dist/devtools-OUIPHVV6.cjs +388 -0
  166. package/dist/devtools-client-4WAPJY5L.cjs +254 -0
  167. package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
  168. package/dist/docs.cjs +46 -5657
  169. package/dist/env-types.cjs +5 -226
  170. package/dist/env.cjs +21 -338
  171. package/dist/environment/vite.cjs +8 -372
  172. package/dist/environment.cjs +12 -94
  173. package/dist/font.cjs +13 -63
  174. package/dist/headers.cjs +7 -123
  175. package/dist/i18n/client.cjs +55 -294
  176. package/dist/i18n/index.cjs +22 -209
  177. package/dist/i18n/server.cjs +22 -745
  178. package/dist/image/server.cjs +13 -729
  179. package/dist/image/sharp.cjs +33 -171
  180. package/dist/image.cjs +41 -85
  181. package/dist/index.cjs +1151 -68080
  182. package/dist/index.mjs +3 -3
  183. package/dist/instrumentation.cjs +12 -138
  184. package/dist/integration-orm-55F7CII5.cjs +13 -0
  185. package/dist/integrations.cjs +55 -4090
  186. package/dist/internal/app-markdown-runtime.cjs +27 -224
  187. package/dist/internal/build-runtime.cjs +120 -52259
  188. package/dist/internal/build-runtime.mjs +3 -3
  189. package/dist/internal/cli-runtime.cjs +67 -13811
  190. package/dist/internal/client-error-overlay.cjs +80 -733
  191. package/dist/internal/client-error-overlay.mjs +1 -1
  192. package/dist/internal/client-runtime.cjs +81 -913
  193. package/dist/internal/compression-runtime.cjs +8 -214
  194. package/dist/internal/config-runtime.cjs +42 -6547
  195. package/dist/internal/docs-precompiled-runtime.cjs +26 -46
  196. package/dist/internal/infra-analytics-runtime.cjs +10 -536
  197. package/dist/internal/isolated-boundary.cjs +14 -414
  198. package/dist/internal/metadata-image-runtime.cjs +7 -285
  199. package/dist/internal/product-telemetry-runtime.cjs +42 -97
  200. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  201. package/dist/internal/production-node-env.cjs +6 -63
  202. package/dist/internal/production-runtime.cjs +418 -7133
  203. package/dist/internal/request-cookies.cjs +6 -54
  204. package/dist/json-ld.cjs +24 -50
  205. package/dist/layers-E4WPJNY5.cjs +17 -0
  206. package/dist/manager-G4B2IPYE.cjs +14 -0
  207. package/dist/markdown.cjs +21 -547
  208. package/dist/middleware.cjs +36 -2995
  209. package/dist/navigation.cjs +22 -2588
  210. package/dist/nitro-4I2MYLY2.cjs +652 -0
  211. package/dist/observability.cjs +22 -614
  212. package/dist/og.cjs +5 -28
  213. package/dist/plugin.cjs +106 -37442
  214. package/dist/plugin.mjs +2 -2
  215. package/dist/query/client.cjs +113 -449
  216. package/dist/query/index.cjs +26 -288
  217. package/dist/query/parsers.cjs +23 -247
  218. package/dist/query/server.cjs +36 -298
  219. package/dist/renderer/react/client.cjs +9 -43
  220. package/dist/renderer/react/server.cjs +40 -103
  221. package/dist/renderer/react/vite.cjs +7 -29
  222. package/dist/renderer-client.cjs +126 -4295
  223. package/dist/renderer.cjs +31 -249
  224. package/dist/request.cjs +5 -68
  225. package/dist/router.cjs +11 -474
  226. package/dist/routes.cjs +42 -2461
  227. package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
  228. package/dist/schema.cjs +6 -33
  229. package/dist/search-client-G3RICOFU.cjs +13 -0
  230. package/dist/server-action-security.cjs +25 -541
  231. package/dist/server-fn-client.cjs +6 -337
  232. package/dist/server-fn.cjs +32 -1841
  233. package/dist/server-plugins.cjs +15 -884
  234. package/dist/server-query-client.cjs +15 -1883
  235. package/dist/server-query.cjs +16 -1838
  236. package/dist/server.cjs +296 -44681
  237. package/dist/server.mjs +2 -2
  238. package/dist/storage.cjs +57 -576
  239. package/dist/testing.cjs +89 -3186
  240. package/dist/theme/client.cjs +13 -108
  241. package/dist/theme/index.cjs +6 -68
  242. package/dist/theme/runtime.cjs +13 -78
  243. package/dist/theme/server.cjs +10 -179
  244. package/dist/version.cjs +4 -32
  245. package/dist/version.mjs +1 -1
  246. package/dist/vite.cjs +119 -37773
  247. package/dist/vite.mjs +2 -2
  248. package/dist/workflows.cjs +19 -1040
  249. package/package.json +1 -1
@@ -0,0 +1,1415 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkAWRISO2Hcjs = require('./chunk-AWRISO2H.cjs');
4
+
5
+
6
+ var _chunkJSROZYYOcjs = require('./chunk-JSROZYYO.cjs');
7
+
8
+
9
+ var _chunkCIAGU2X4cjs = require('./chunk-CIAGU2X4.cjs');
10
+
11
+
12
+ var _chunkSYQ3MOWWcjs = require('./chunk-SYQ3MOWW.cjs');
13
+
14
+
15
+
16
+ var _chunk6EODJYCXcjs = require('./chunk-6EODJYCX.cjs');
17
+
18
+
19
+ var _chunkTIWHTW3Qcjs = require('./chunk-TIWHTW3Q.cjs');
20
+
21
+
22
+
23
+ var _chunkY4YMF2NQcjs = require('./chunk-Y4YMF2NQ.cjs');
24
+
25
+
26
+ var _chunkTFAXUHWXcjs = require('./chunk-TFAXUHWX.cjs');
27
+
28
+
29
+ var _chunkIAMRBF3Zcjs = require('./chunk-IAMRBF3Z.cjs');
30
+
31
+
32
+ var _chunkIQXFRNY2cjs = require('./chunk-IQXFRNY2.cjs');
33
+
34
+
35
+ var _chunkI4J452B7cjs = require('./chunk-I4J452B7.cjs');
36
+
37
+
38
+ var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
39
+
40
+
41
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
42
+
43
+ // src/ssg.ts
44
+ var _promises = require('fs/promises');
45
+ var OPTIONAL_CATCH_ALL_SEGMENT = /^\[\[\.\.\.([^\]]+)\]\]$/;
46
+ var REQUIRED_CATCH_ALL_SEGMENT = /^\[\.\.\.([^\]]+)\]$/;
47
+ var REQUIRED_DYNAMIC_SEGMENT = /^\[([^\]]+)\]$/;
48
+ var REQUEST_API_LABELS = /* @__PURE__ */ new Map([
49
+ ["cookies", "request cookies"],
50
+ ["headers", "request headers"],
51
+ ["getCurrentRequest", "the current Request"],
52
+ ["useSearchParams", "URL search parameters"],
53
+ ["auth", "request authentication"],
54
+ ["getServerSession", "request authentication"],
55
+ ["getSession", "request authentication"],
56
+ ["currentUser", "request authentication"]
57
+ ]);
58
+ var ROUTE_PROP_LABELS = /* @__PURE__ */ new Map([
59
+ ["searchParams", "URL search parameters"],
60
+ ["middleware", "middleware request data"],
61
+ ["middlewareData", "middleware request data"],
62
+ ["context", "request context"]
63
+ ]);
64
+ function resolveConfiguredRouteRenderingConfig(mod, source, options) {
65
+ return _chunkSYQ3MOWWcjs.mergeRouteRenderingDirectiveConfig.call(void 0, parseRouteRenderingDirective(source), mod, options);
66
+ }
67
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveConfiguredRouteRenderingConfig, "resolveConfiguredRouteRenderingConfig");
68
+ function resolveRouteRenderingConfig(mod, source, options) {
69
+ const rendering = resolveConfiguredRouteRenderingConfig(mod, source, options);
70
+ if (!rendering.ssg || !source) {
71
+ return rendering;
72
+ }
73
+ const requestBlockers = findRequestBoundSourceBlockers(source);
74
+ if (requestBlockers.length === 0) {
75
+ return rendering;
76
+ }
77
+ return {
78
+ ...rendering,
79
+ ssg: false,
80
+ revalidate: void 0
81
+ };
82
+ }
83
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveRouteRenderingConfig, "resolveRouteRenderingConfig");
84
+ async function resolveRouteRenderingConfigFromFile(mod, filePath, options) {
85
+ const source = await _promises.readFile.call(void 0, filePath, "utf8").catch(() => void 0);
86
+ return resolveRouteRenderingConfig(mod, source, options);
87
+ }
88
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveRouteRenderingConfigFromFile, "resolveRouteRenderingConfigFromFile");
89
+ function analyzeStaticRouteCandidate(mod, source, options = {}) {
90
+ const blockers = [];
91
+ if (!source) {
92
+ blockers.push("route source is unavailable");
93
+ }
94
+ if (options.isDynamic) {
95
+ blockers.push("the route has dynamic path segments");
96
+ }
97
+ if (hasExplicitRenderingConfig(mod, source)) {
98
+ blockers.push("the route already has explicit rendering config");
99
+ }
100
+ if (source) {
101
+ blockers.push(...findRequestBoundSourceBlockers(source));
102
+ }
103
+ return {
104
+ candidate: blockers.length === 0,
105
+ blockers
106
+ };
107
+ }
108
+ _chunkS3JO3N4Hcjs.__name.call(void 0, analyzeStaticRouteCandidate, "analyzeStaticRouteCandidate");
109
+ function findRequestBoundSourceBlockers(source) {
110
+ const blockers = /* @__PURE__ */ new Set();
111
+ const code = stripCommentsAndLiteralContents(source);
112
+ const sourceWithoutComments = stripComments(source);
113
+ for (const binding of readRequestApiImportBindings(sourceWithoutComments)) {
114
+ if (new RegExp(`\\b${escapeRegExp(binding.local)}\\s*(?:\\?\\.\\s*)?\\(`).test(code)) {
115
+ blockers.add(`the route reads ${binding.label}`);
116
+ }
117
+ }
118
+ for (const namespace of readNamespaceImportBindings(sourceWithoutComments)) {
119
+ for (const [name, label] of REQUEST_API_LABELS) {
120
+ if (new RegExp(
121
+ `\\b${escapeRegExp(namespace)}\\s*(?:\\?\\.\\s*|\\.\\s*)${name}\\s*(?:\\?\\.\\s*)?\\(`
122
+ ).test(code)) {
123
+ blockers.add(`the route reads ${label}`);
124
+ }
125
+ }
126
+ }
127
+ const params = readDefaultRouteParameters(code);
128
+ if (params) {
129
+ for (const [name, label] of ROUTE_PROP_LABELS) {
130
+ if (new RegExp(`\\b${name}\\b`).test(params)) {
131
+ blockers.add(`the route reads ${label}`);
132
+ }
133
+ }
134
+ const propsName = _optionalChain([params, 'access', _ => _.match, 'call', _2 => _2(/^\s*([A-Za-z_$][\w$]*)\s*(?::|,|$)/), 'optionalAccess', _3 => _3[1]]);
135
+ if (propsName) {
136
+ for (const [name, label] of ROUTE_PROP_LABELS) {
137
+ if (new RegExp(`\\b${escapeRegExp(propsName)}\\s*\\.\\s*${name}\\b`).test(code)) {
138
+ blockers.add(`the route reads ${label}`);
139
+ }
140
+ if (new RegExp(`\\{[^}]*\\b${name}\\b[^}]*\\}\\s*=\\s*${escapeRegExp(propsName)}\\b`).test(
141
+ code
142
+ )) {
143
+ blockers.add(`the route reads ${label}`);
144
+ }
145
+ }
146
+ }
147
+ }
148
+ return [...blockers];
149
+ }
150
+ _chunkS3JO3N4Hcjs.__name.call(void 0, findRequestBoundSourceBlockers, "findRequestBoundSourceBlockers");
151
+ function readRequestApiImportBindings(source) {
152
+ const bindings = [];
153
+ for (const clause of readStaticImportClauses(source)) {
154
+ const namedGroup = _optionalChain([clause, 'access', _4 => _4.match, 'call', _5 => _5(/\{([\s\S]*?)\}/), 'optionalAccess', _6 => _6[1]]);
155
+ for (const rawSpecifier of (_nullishCoalesce(namedGroup, () => ( ""))).split(",")) {
156
+ const specifier = rawSpecifier.trim().replace(/^type\s+/, "");
157
+ const imported = specifier.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);
158
+ if (!_optionalChain([imported, 'optionalAccess', _7 => _7[1]])) continue;
159
+ const label = REQUEST_API_LABELS.get(imported[1]);
160
+ if (label) bindings.push({ local: _nullishCoalesce(imported[2], () => ( imported[1])), label });
161
+ }
162
+ const local = _optionalChain([clause, 'access', _8 => _8.match, 'call', _9 => _9(/^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/), 'optionalAccess', _10 => _10[1]]);
163
+ if (local) {
164
+ const label = REQUEST_API_LABELS.get(local);
165
+ if (label) bindings.push({ local, label });
166
+ }
167
+ }
168
+ return bindings;
169
+ }
170
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readRequestApiImportBindings, "readRequestApiImportBindings");
171
+ function readNamespaceImportBindings(source) {
172
+ return readStaticImportClauses(source).map((clause) => _optionalChain([clause, 'access', _11 => _11.match, 'call', _12 => _12(/\*\s*as\s*([A-Za-z_$][\w$]*)/), 'optionalAccess', _13 => _13[1]])).filter((binding) => Boolean(binding));
173
+ }
174
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readNamespaceImportBindings, "readNamespaceImportBindings");
175
+ function readStaticImportClauses(source) {
176
+ return [...source.matchAll(/\bimport\s+(?!\()([\s\S]*?)\s+from\s*["'][^"']+["']/g)].map((match) => match[1]).filter((clause) => Boolean(clause));
177
+ }
178
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readStaticImportClauses, "readStaticImportClauses");
179
+ function readDefaultRouteParameters(code) {
180
+ const inlineParams = _nullishCoalesce(_optionalChain([code, 'access', _14 => _14.match, 'call', _15 => _15(/\bexport\s+default\s+(?:async\s+)?function\b[^(]*\(([^)]*)\)/), 'optionalAccess', _16 => _16[1]]), () => ( _optionalChain([code, 'access', _17 => _17.match, 'call', _18 => _18(/\bexport\s+default\s+(?:async\s+)?\(([^)]*)\)\s*=>/), 'optionalAccess', _19 => _19[1]])));
181
+ if (inlineParams !== void 0) return inlineParams;
182
+ const binding = _nullishCoalesce(_optionalChain([code, 'access', _20 => _20.match, 'call', _21 => _21(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/), 'optionalAccess', _22 => _22[1]]), () => ( _optionalChain([code, 'access', _23 => _23.match, 'call', _24 => _24(/\bexport\s*\{\s*([A-Za-z_$][\w$]*)\s+as\s+default\s*\}/), 'optionalAccess', _25 => _25[1]])));
183
+ if (!binding) return void 0;
184
+ const escapedBinding = escapeRegExp(binding);
185
+ return _nullishCoalesce(_nullishCoalesce(_optionalChain([code, 'access', _26 => _26.match, 'call', _27 => _27(new RegExp(`\\bfunction\\s+${escapedBinding}\\s*\\(([^)]*)\\)`)), 'optionalAccess', _28 => _28[1]]), () => ( _optionalChain([code, 'access', _29 => _29.match, 'call', _30 => _30(
186
+ new RegExp(
187
+ `\\b(?:const|let|var)\\s+${escapedBinding}\\s*=\\s*(?:async\\s+)?\\(([^)]*)\\)\\s*=>`
188
+ )
189
+ ), 'optionalAccess', _31 => _31[1]]))), () => ( _optionalChain([code, 'access', _32 => _32.match, 'call', _33 => _33(
190
+ new RegExp(`\\b(?:const|let|var)\\s+${escapedBinding}\\s*=\\s*function\\s*\\(([^)]*)\\)`)
191
+ ), 'optionalAccess', _34 => _34[1]])));
192
+ }
193
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readDefaultRouteParameters, "readDefaultRouteParameters");
194
+ function stripCommentsAndLiteralContents(source) {
195
+ return sanitizeSource(source, true);
196
+ }
197
+ _chunkS3JO3N4Hcjs.__name.call(void 0, stripCommentsAndLiteralContents, "stripCommentsAndLiteralContents");
198
+ function stripComments(source) {
199
+ return sanitizeSource(source, false);
200
+ }
201
+ _chunkS3JO3N4Hcjs.__name.call(void 0, stripComments, "stripComments");
202
+ function sanitizeSource(source, maskLiterals) {
203
+ const output = [...source];
204
+ const mask = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (index) => {
205
+ if (output[index] !== "\n" && output[index] !== "\r") output[index] = " ";
206
+ }, "mask");
207
+ const scanQuoted = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (start, quote) => {
208
+ let index = start;
209
+ if (maskLiterals) mask(index);
210
+ index += 1;
211
+ while (index < source.length) {
212
+ if (source[index] === "\\") {
213
+ if (maskLiterals) mask(index);
214
+ if (index + 1 < source.length && maskLiterals) mask(index + 1);
215
+ index += 2;
216
+ continue;
217
+ }
218
+ const character = source[index];
219
+ if (maskLiterals) mask(index);
220
+ index += 1;
221
+ if (character === quote) break;
222
+ }
223
+ return index;
224
+ }, "scanQuoted");
225
+ const scanCode = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (start, stopAtTemplateBrace) => {
226
+ let index = start;
227
+ let braceDepth = 0;
228
+ while (index < source.length) {
229
+ const character = source[index];
230
+ const next = source[index + 1];
231
+ if (character === "/" && next === "/") {
232
+ while (index < source.length && source[index] !== "\n" && source[index] !== "\r") {
233
+ mask(index++);
234
+ }
235
+ continue;
236
+ }
237
+ if (character === "/" && next === "*") {
238
+ mask(index++);
239
+ mask(index++);
240
+ while (index < source.length) {
241
+ const closesComment = source[index] === "*" && source[index + 1] === "/";
242
+ mask(index++);
243
+ if (closesComment) {
244
+ mask(index++);
245
+ break;
246
+ }
247
+ }
248
+ continue;
249
+ }
250
+ if (character === "'" || character === '"') {
251
+ index = scanQuoted(index, character);
252
+ continue;
253
+ }
254
+ if (character === "`") {
255
+ if (maskLiterals) mask(index);
256
+ index += 1;
257
+ while (index < source.length) {
258
+ if (source[index] === "\\") {
259
+ if (maskLiterals) mask(index);
260
+ if (index + 1 < source.length && maskLiterals) mask(index + 1);
261
+ index += 2;
262
+ } else if (source[index] === "`") {
263
+ if (maskLiterals) mask(index);
264
+ index += 1;
265
+ break;
266
+ } else if (source[index] === "$" && source[index + 1] === "{") {
267
+ if (maskLiterals) {
268
+ mask(index);
269
+ mask(index + 1);
270
+ }
271
+ index = scanCode(index + 2, true);
272
+ } else {
273
+ if (maskLiterals) mask(index);
274
+ index += 1;
275
+ }
276
+ }
277
+ continue;
278
+ }
279
+ if (character === "{") {
280
+ braceDepth += 1;
281
+ } else if (character === "}") {
282
+ if (stopAtTemplateBrace && braceDepth === 0) {
283
+ if (maskLiterals) mask(index);
284
+ return index + 1;
285
+ }
286
+ braceDepth = Math.max(0, braceDepth - 1);
287
+ }
288
+ index += 1;
289
+ }
290
+ return index;
291
+ }, "scanCode");
292
+ scanCode(0, false);
293
+ return output.join("");
294
+ }
295
+ _chunkS3JO3N4Hcjs.__name.call(void 0, sanitizeSource, "sanitizeSource");
296
+ function escapeRegExp(value) {
297
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
298
+ }
299
+ _chunkS3JO3N4Hcjs.__name.call(void 0, escapeRegExp, "escapeRegExp");
300
+ function hasExplicitRenderingConfig(mod, source) {
301
+ return typeof _optionalChain([mod, 'optionalAccess', _35 => _35.ssg]) === "boolean" || typeof _optionalChain([mod, 'optionalAccess', _36 => _36.ppr]) === "boolean" || typeof _optionalChain([mod, 'optionalAccess', _37 => _37.experimental_ppr]) === "boolean" || typeof _optionalChain([mod, 'optionalAccess', _38 => _38.revalidate]) !== "undefined" || typeof _optionalChain([mod, 'optionalAccess', _39 => _39.dynamic]) !== "undefined" || typeof parseRouteRenderingDirective(source) !== "undefined";
302
+ }
303
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hasExplicitRenderingConfig, "hasExplicitRenderingConfig");
304
+ function parseRouteRenderingDirective(source) {
305
+ if (!source) {
306
+ return void 0;
307
+ }
308
+ for (const directive of readDirectivePrologue(source)) {
309
+ const config = parseKnownRenderingDirective(directive);
310
+ if (config) {
311
+ return config;
312
+ }
313
+ }
314
+ return void 0;
315
+ }
316
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseRouteRenderingDirective, "parseRouteRenderingDirective");
317
+ function parseKnownRenderingDirective(directive) {
318
+ const normalized = directive.trim().toLowerCase();
319
+ const match = normalized.match(
320
+ /^use\s+(ssg|static|isr|ssr|dynamic|ppr)(?:\s*[;:]\s*(\d+))?\s*;?$/
321
+ );
322
+ if (!_optionalChain([match, 'optionalAccess', _40 => _40[1]])) {
323
+ return void 0;
324
+ }
325
+ const mode = match[1];
326
+ const revalidate = match[2] ? Number(match[2]) : void 0;
327
+ if (mode === "ssr" || mode === "dynamic") {
328
+ return {
329
+ ssg: false,
330
+ ppr: false,
331
+ dynamic: "force-dynamic",
332
+ directive
333
+ };
334
+ }
335
+ if (mode === "ppr") {
336
+ return {
337
+ ssg: false,
338
+ ppr: true,
339
+ revalidate: typeof revalidate === "number" && revalidate > 0 ? revalidate : void 0,
340
+ directive
341
+ };
342
+ }
343
+ return {
344
+ ssg: true,
345
+ ppr: false,
346
+ dynamic: "force-static",
347
+ revalidate: typeof revalidate === "number" && revalidate > 0 ? revalidate : void 0,
348
+ directive
349
+ };
350
+ }
351
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseKnownRenderingDirective, "parseKnownRenderingDirective");
352
+ function readDirectivePrologue(source) {
353
+ const directives = [];
354
+ let index = skipTrivia(source, 0);
355
+ while (index < source.length) {
356
+ const parsed = readStringStatement(source, index);
357
+ if (!parsed) {
358
+ break;
359
+ }
360
+ directives.push(parsed.value);
361
+ index = skipTrivia(source, parsed.end);
362
+ }
363
+ return directives;
364
+ }
365
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readDirectivePrologue, "readDirectivePrologue");
366
+ function skipTrivia(source, start) {
367
+ let index = start;
368
+ while (index < source.length) {
369
+ const char = source[index];
370
+ if (char && /\s/.test(char)) {
371
+ index += 1;
372
+ continue;
373
+ }
374
+ if (source.startsWith("//", index)) {
375
+ const nextLine = source.indexOf("\n", index + 2);
376
+ index = nextLine === -1 ? source.length : nextLine + 1;
377
+ continue;
378
+ }
379
+ if (source.startsWith("/*", index)) {
380
+ const end = source.indexOf("*/", index + 2);
381
+ index = end === -1 ? source.length : end + 2;
382
+ continue;
383
+ }
384
+ break;
385
+ }
386
+ return index;
387
+ }
388
+ _chunkS3JO3N4Hcjs.__name.call(void 0, skipTrivia, "skipTrivia");
389
+ function readStringStatement(source, start) {
390
+ const quote = source[start];
391
+ if (quote !== '"' && quote !== "'") {
392
+ return void 0;
393
+ }
394
+ let value = "";
395
+ let index = start + 1;
396
+ while (index < source.length) {
397
+ const char = source[index];
398
+ if (char === "\\") {
399
+ value += source.slice(index, index + 2);
400
+ index += 2;
401
+ continue;
402
+ }
403
+ if (char === quote) {
404
+ index += 1;
405
+ const semicolonIndex = skipHorizontalWhitespace(source, index);
406
+ const end = source[semicolonIndex] === ";" ? semicolonIndex + 1 : index;
407
+ return { value, end };
408
+ }
409
+ value += _nullishCoalesce(char, () => ( ""));
410
+ index += 1;
411
+ }
412
+ return void 0;
413
+ }
414
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readStringStatement, "readStringStatement");
415
+ function skipHorizontalWhitespace(source, start) {
416
+ let index = start;
417
+ while (source[index] === " " || source[index] === " " || source[index] === "\r") {
418
+ index += 1;
419
+ }
420
+ return index;
421
+ }
422
+ _chunkS3JO3N4Hcjs.__name.call(void 0, skipHorizontalWhitespace, "skipHorizontalWhitespace");
423
+ async function collectSSGPages(routes, loadModule, options = {}) {
424
+ const ssgPages = [];
425
+ const ssrRoutes = [];
426
+ const staticCandidateRoutes = [];
427
+ for (const route of routes) {
428
+ try {
429
+ const mod = await loadModule(route.filePath);
430
+ if (!mod) {
431
+ ssrRoutes.push(route.path);
432
+ continue;
433
+ }
434
+ const source = await _promises.readFile.call(void 0, route.filePath, "utf8").catch(() => void 0);
435
+ const configuredRendering = resolveConfiguredRouteRenderingConfig(mod, source);
436
+ const rendering = resolveRouteRenderingConfig(mod, source);
437
+ if (configuredRendering.ssg && !rendering.ssg && source) {
438
+ const blockers = findRequestBoundSourceBlockers(source);
439
+ console.warn(
440
+ `[Farm.js] Static rendering disabled for "${route.path}" because ${blockers.join(
441
+ " and "
442
+ )}. Farm will render this route on each request instead.`
443
+ );
444
+ }
445
+ if (rendering.ssg) {
446
+ if (route.isDynamic) {
447
+ const getStaticPaths = mod.getStaticPaths || mod.generateStaticParams;
448
+ if (!getStaticPaths) {
449
+ throw new Error(
450
+ `Dynamic SSG route "${route.path}" requires getStaticPaths export. Add: export function getStaticPaths() { return [{ paramName: 'value' }]; }`
451
+ );
452
+ }
453
+ const paths = await getStaticPaths();
454
+ const optionalCatchAllParams = getOptionalCatchAllParameterNames(route.path);
455
+ const materializedPages = paths.map((params) => ({
456
+ urlPath: materializeSSGRoutePath(route.path, params),
457
+ filePath: route.filePath,
458
+ params: normalizeStaticPathParams(params, optionalCatchAllParams),
459
+ revalidate: rendering.revalidate
460
+ }));
461
+ ssgPages.push(...materializedPages);
462
+ } else {
463
+ ssgPages.push({
464
+ urlPath: route.path,
465
+ filePath: route.filePath,
466
+ params: {},
467
+ revalidate: rendering.revalidate
468
+ });
469
+ }
470
+ } else {
471
+ ssrRoutes.push(route.path);
472
+ if (options.suggestStaticRendering !== false && analyzeStaticRouteCandidate(mod, source, { isDynamic: route.isDynamic }).candidate) {
473
+ staticCandidateRoutes.push(route.path);
474
+ }
475
+ }
476
+ } catch (error) {
477
+ console.error(`Error processing route ${route.path}:`, error);
478
+ ssrRoutes.push(route.path);
479
+ }
480
+ }
481
+ if (staticCandidateRoutes.length > 0) {
482
+ const visibleRoutes = staticCandidateRoutes.slice(0, 10);
483
+ const remainingCount = staticCandidateRoutes.length - visibleRoutes.length;
484
+ const remainingSuffix = remainingCount > 0 ? `
485
+ \u2026and ${remainingCount} more` : "";
486
+ console.warn(
487
+ `[Farm.js] ${staticCandidateRoutes.length} route${staticCandidateRoutes.length === 1 ? " appears" : "s appear"} eligible for static rendering:
488
+ ${visibleRoutes.join("\n ")}${remainingSuffix}
489
+ Add \`export const dynamic = "force-static";\` after verifying that imported code does not read cookies, headers, authentication, or other request data.`
490
+ );
491
+ }
492
+ return { ssg: ssgPages, ssr: ssrRoutes };
493
+ }
494
+ _chunkS3JO3N4Hcjs.__name.call(void 0, collectSSGPages, "collectSSGPages");
495
+ function materializeSSGRoutePath(routePattern, params) {
496
+ const outputSegments = [];
497
+ for (const segment of routePattern.split("/")) {
498
+ if (!segment) {
499
+ continue;
500
+ }
501
+ const optionalCatchAll = segment.match(OPTIONAL_CATCH_ALL_SEGMENT);
502
+ if (optionalCatchAll) {
503
+ const parameterName = optionalCatchAll[1];
504
+ const value = params[parameterName];
505
+ const values = readCatchAllSegments(value, {
506
+ optional: true,
507
+ parameterName,
508
+ routePattern
509
+ });
510
+ outputSegments.push(...values.map(encodePathSegment));
511
+ continue;
512
+ }
513
+ const requiredCatchAll = segment.match(REQUIRED_CATCH_ALL_SEGMENT);
514
+ if (requiredCatchAll) {
515
+ const parameterName = requiredCatchAll[1];
516
+ const value = params[parameterName];
517
+ const values = readCatchAllSegments(value, {
518
+ optional: false,
519
+ parameterName,
520
+ routePattern
521
+ });
522
+ outputSegments.push(...values.map(encodePathSegment));
523
+ continue;
524
+ }
525
+ const requiredDynamic = segment.match(REQUIRED_DYNAMIC_SEGMENT);
526
+ if (requiredDynamic) {
527
+ const parameterName = requiredDynamic[1];
528
+ const value = params[parameterName];
529
+ if (isStaticPathArray(value)) {
530
+ throw new Error(
531
+ `Cannot materialize SSG route "${routePattern}": parameter "${parameterName}" must be a scalar value; arrays are only supported for catch-all segments.`
532
+ );
533
+ }
534
+ if (isMissingPathValue(value)) {
535
+ throw missingRequiredParameterError(routePattern, parameterName);
536
+ }
537
+ outputSegments.push(encodePathSegment(value));
538
+ continue;
539
+ }
540
+ outputSegments.push(segment);
541
+ }
542
+ return outputSegments.length > 0 ? `/${outputSegments.join("/")}` : "/";
543
+ }
544
+ _chunkS3JO3N4Hcjs.__name.call(void 0, materializeSSGRoutePath, "materializeSSGRoutePath");
545
+ function readCatchAllSegments(value, options) {
546
+ if (isMissingPathValue(value) || isStaticPathArray(value) && value.length === 0) {
547
+ if (options.optional) {
548
+ return [];
549
+ }
550
+ throw missingRequiredParameterError(options.routePattern, options.parameterName);
551
+ }
552
+ const segments = isStaticPathArray(value) ? [...value] : [value];
553
+ if (segments.some(isMissingPathValue)) {
554
+ throw new Error(
555
+ `Cannot materialize SSG route "${options.routePattern}": catch-all parameter "${options.parameterName}" contains an empty path segment.`
556
+ );
557
+ }
558
+ return segments;
559
+ }
560
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readCatchAllSegments, "readCatchAllSegments");
561
+ function getOptionalCatchAllParameterNames(routePattern) {
562
+ return new Set(
563
+ routePattern.split("/").map((segment) => _optionalChain([segment, 'access', _41 => _41.match, 'call', _42 => _42(OPTIONAL_CATCH_ALL_SEGMENT), 'optionalAccess', _43 => _43[1]])).filter((name) => Boolean(name))
564
+ );
565
+ }
566
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getOptionalCatchAllParameterNames, "getOptionalCatchAllParameterNames");
567
+ function normalizeStaticPathParams(params, optionalCatchAllParams) {
568
+ const entries = Object.entries(params).map(([key, value]) => {
569
+ const emptyOptionalCatchAll = optionalCatchAllParams.has(key) && (isMissingPathValue(value) || isStaticPathArray(value) && value.length === 0);
570
+ return [
571
+ key,
572
+ emptyOptionalCatchAll ? "" : isStaticPathArray(value) ? value.map(String).join("/") : String(value)
573
+ ];
574
+ });
575
+ for (const name of optionalCatchAllParams) {
576
+ if (!Object.prototype.hasOwnProperty.call(params, name)) {
577
+ entries.push([name, ""]);
578
+ }
579
+ }
580
+ return Object.fromEntries(entries);
581
+ }
582
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeStaticPathParams, "normalizeStaticPathParams");
583
+ function isMissingPathValue(value) {
584
+ return value === "" || value === null || typeof value === "undefined";
585
+ }
586
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isMissingPathValue, "isMissingPathValue");
587
+ function isStaticPathArray(value) {
588
+ return Array.isArray(value);
589
+ }
590
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isStaticPathArray, "isStaticPathArray");
591
+ function missingRequiredParameterError(routePattern, parameterName) {
592
+ return new Error(
593
+ `Cannot materialize SSG route "${routePattern}": required parameter "${parameterName}" is missing or empty.`
594
+ );
595
+ }
596
+ _chunkS3JO3N4Hcjs.__name.call(void 0, missingRequiredParameterError, "missingRequiredParameterError");
597
+ function encodePathSegment(value) {
598
+ const encoded = encodeURIComponent(String(value)).replace(
599
+ /[!'()*]/g,
600
+ (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
601
+ );
602
+ if (encoded === "." || encoded === "..") {
603
+ throw new Error(
604
+ `Cannot materialize SSG path segment "${encoded}": dot-only segments are unsafe to prerender.`
605
+ );
606
+ }
607
+ return encoded;
608
+ }
609
+ _chunkS3JO3N4Hcjs.__name.call(void 0, encodePathSegment, "encodePathSegment");
610
+ function isSSGModule(mod) {
611
+ return resolveRouteRenderingConfig(mod).ssg;
612
+ }
613
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isSSGModule, "isSSGModule");
614
+ function hasISR(mod) {
615
+ const rendering = resolveRouteRenderingConfig(mod);
616
+ return rendering.ssg && typeof rendering.revalidate === "number" && rendering.revalidate > 0;
617
+ }
618
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hasISR, "hasISR");
619
+ function getRevalidateInterval(mod) {
620
+ return resolveRouteRenderingConfig(mod).revalidate;
621
+ }
622
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRevalidateInterval, "getRevalidateInterval");
623
+ function hasPPR(mod, options) {
624
+ return resolveRouteRenderingConfig(mod, void 0, options).ppr;
625
+ }
626
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hasPPR, "hasPPR");
627
+ function generateSSGManifest(pages) {
628
+ return JSON.stringify(
629
+ pages.map((page) => ({
630
+ urlPath: page.urlPath,
631
+ params: page.params,
632
+ revalidate: page.revalidate
633
+ })),
634
+ null,
635
+ 2
636
+ );
637
+ }
638
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateSSGManifest, "generateSSGManifest");
639
+ function matchSSGPage(urlPath, ssgPages) {
640
+ const normalizedPath = urlPath === "/" ? "/" : urlPath.replace(/\/$/, "");
641
+ return ssgPages.find((page) => page.urlPath === normalizedPath);
642
+ }
643
+ _chunkS3JO3N4Hcjs.__name.call(void 0, matchSSGPage, "matchSSGPage");
644
+
645
+ // src/routing/generate-route-types.ts
646
+ var _path = require('path'); var path = _interopRequireWildcard(_path); var path3 = _interopRequireWildcard(_path);
647
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs); var fs2 = _interopRequireWildcard(_fs);
648
+
649
+ // src/routing/route-slots.ts
650
+ var SLOT_SEGMENT = /^@([A-Za-z][A-Za-z0-9_-]*)$/;
651
+ function parseRouteSlotFile(filePath) {
652
+ const normalized = filePath.replace(/\\/g, "/");
653
+ const parts = normalized.split("/").filter(Boolean);
654
+ const fileName = _nullishCoalesce(parts.at(-1), () => ( ""));
655
+ const baseName = fileName.replace(/\.(tsx?|jsx?|vue|svelte)$/, "");
656
+ if (baseName !== "page" && baseName !== "default") return null;
657
+ const slotIndex = parts.findIndex((part) => SLOT_SEGMENT.test(part));
658
+ if (slotIndex < 0) return null;
659
+ if (parts.slice(slotIndex + 1, -1).some((part) => SLOT_SEGMENT.test(part))) {
660
+ throw new Error(`Nested route slots are not supported in "${filePath}"`);
661
+ }
662
+ const slotMatch = parts[slotIndex].match(SLOT_SEGMENT);
663
+ const name = _optionalChain([slotMatch, 'optionalAccess', _44 => _44[1]]);
664
+ if (!name) return null;
665
+ const ownerParts = parts.slice(0, slotIndex);
666
+ const contentParts = parts.slice(slotIndex + 1, -1);
667
+ const marker = parseInterceptionMarker(contentParts[0]);
668
+ let targetBase = ownerParts;
669
+ let targetParts = contentParts;
670
+ if (marker) {
671
+ targetBase = marker.root === true ? [] : ownerParts.slice(0, Math.max(0, ownerParts.length - marker.up));
672
+ targetParts = [...marker.remainder ? [marker.remainder] : [], ...contentParts.slice(1)];
673
+ }
674
+ const ownerFile = [...ownerParts, "layout.tsx"].join("/");
675
+ const routeFile = [
676
+ ...baseName === "default" ? ownerParts : targetBase,
677
+ ...baseName === "default" ? [] : targetParts,
678
+ "page.tsx"
679
+ ].join("/");
680
+ return {
681
+ name,
682
+ ownerRoute: _chunk5QIKR7RRcjs.parseRoutePath.call(void 0, ownerFile || "layout.tsx"),
683
+ route: _chunk5QIKR7RRcjs.parseRoutePath.call(void 0, routeFile || "page.tsx"),
684
+ interception: marker !== null,
685
+ fallback: baseName === "default"
686
+ };
687
+ }
688
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseRouteSlotFile, "parseRouteSlotFile");
689
+ function createRouteSlotContainerId(name, ownerPattern) {
690
+ const owner = ownerPattern === "/" ? "root" : ownerPattern.replace(/^\//, "").replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
691
+ return `__farm_slot_${name}_${owner || "root"}__`;
692
+ }
693
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createRouteSlotContainerId, "createRouteSlotContainerId");
694
+ function parseInterceptionMarker(segment) {
695
+ if (!segment) return null;
696
+ if (segment.startsWith("(...)")) {
697
+ return {
698
+ up: 0,
699
+ root: true,
700
+ remainder: segment.slice(5)
701
+ };
702
+ }
703
+ if (segment.startsWith("(.)")) {
704
+ return {
705
+ up: 0,
706
+ remainder: segment.slice(3)
707
+ };
708
+ }
709
+ let remainder = segment;
710
+ let up = 0;
711
+ while (remainder.startsWith("(..)")) {
712
+ up += 1;
713
+ remainder = remainder.slice(4);
714
+ }
715
+ return up > 0 ? { up, remainder } : null;
716
+ }
717
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseInterceptionMarker, "parseInterceptionMarker");
718
+
719
+ // src/routing/generate-route-types.ts
720
+ function routeSegmentsToTsTypeLiteral(segments) {
721
+ if (segments.length === 0) return '"/"';
722
+ const hasDynamic = segments.some((s) => s.startsWith("["));
723
+ if (!hasDynamic) return JSON.stringify("/" + segments.join("/"));
724
+ const parts = segments.map((s) => {
725
+ if (s.startsWith("[[...") || s.startsWith("[...")) return "${string}";
726
+ if (s.startsWith("[")) return "${string}";
727
+ return s;
728
+ });
729
+ return "`/" + parts.join("/") + "`";
730
+ }
731
+ _chunkS3JO3N4Hcjs.__name.call(void 0, routeSegmentsToTsTypeLiteral, "routeSegmentsToTsTypeLiteral");
732
+ function routePatternToTsTypeLiterals(pattern) {
733
+ if (pattern === "/") return ['"/"'];
734
+ let variants = [[]];
735
+ for (const segment of pattern.slice(1).split("/").filter(Boolean)) {
736
+ if (segment.startsWith("[[...") && segment.endsWith("]]")) {
737
+ variants = variants.flatMap((parts) => [parts, [...parts, segment]]);
738
+ } else {
739
+ variants = variants.map((parts) => [...parts, segment]);
740
+ }
741
+ }
742
+ return variants.map(routeSegmentsToTsTypeLiteral);
743
+ }
744
+ _chunkS3JO3N4Hcjs.__name.call(void 0, routePatternToTsTypeLiterals, "routePatternToTsTypeLiterals");
745
+ function routePatternToRouteLiteral(pattern) {
746
+ return JSON.stringify(pattern);
747
+ }
748
+ _chunkS3JO3N4Hcjs.__name.call(void 0, routePatternToRouteLiteral, "routePatternToRouteLiteral");
749
+ function renderTypeUnion(values) {
750
+ return values.length <= 1 ? values[0] || "never" : `
751
+ | ${values.join("\n | ")}`;
752
+ }
753
+ _chunkS3JO3N4Hcjs.__name.call(void 0, renderTypeUnion, "renderTypeUnion");
754
+ function renderTypeAlias(name, value) {
755
+ return `export type ${name} =${value.startsWith("\n") ? "" : " "}${value};`;
756
+ }
757
+ _chunkS3JO3N4Hcjs.__name.call(void 0, renderTypeAlias, "renderTypeAlias");
758
+ function createRoutePattern(route) {
759
+ if (route.segments.length === 0) return "/";
760
+ return "/" + route.segments.map((seg) => {
761
+ if (!seg.isDynamic) return seg.segment;
762
+ if (seg.isCatchAll) return seg.isOptional ? `[[...${seg.segment}]]` : `[...${seg.segment}]`;
763
+ return `[${seg.segment}]`;
764
+ }).join("/");
765
+ }
766
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createRoutePattern, "createRoutePattern");
767
+ var DEFAULT_OUT_FILE = "farm-routes.d.ts";
768
+ async function generateRouteTypes(options) {
769
+ const root = path.resolve(options.root);
770
+ const srcDir = options.srcDir || "src";
771
+ const outFile = options.outFile || DEFAULT_OUT_FILE;
772
+ const outPath = path.isAbsolute(outFile) ? outFile : path.join(root, srcDir, outFile);
773
+ const content = await createRouteTypeDeclarations(options, outPath);
774
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
775
+ _chunkTIWHTW3Qcjs.writeFileIfChanged.call(void 0, outPath, content);
776
+ return outPath;
777
+ }
778
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateRouteTypes, "generateRouteTypes");
779
+ async function createRouteTypeDeclarations(options, outPath) {
780
+ const { root, srcDir = "src", extraRoutes = [], suppressLintOnLink = false } = options;
781
+ const sourceRoots = _nullishCoalesce(options.sourceRoots, () => ( [{ name: "project", root, srcDir, layer: false }]));
782
+ const componentExtensions = _chunkTFAXUHWXcjs.resolveFarmComponentExtensions.call(void 0, options.componentExtensions).map(
783
+ (extension) => extension.slice(1)
784
+ );
785
+ const patterns = /* @__PURE__ */ new Set();
786
+ const routeModulePatterns = /* @__PURE__ */ new Set();
787
+ const glob = await import("fast-glob");
788
+ for (const source of sourceRoots) {
789
+ const appDir = path.join(source.root, source.srcDir, "app");
790
+ if (fs.existsSync(appDir)) {
791
+ const routeModuleFiles = await glob.default(
792
+ `**/{page,layout,loading,error}.{${componentExtensions.join(",")},md,mdx}`,
793
+ {
794
+ cwd: appDir,
795
+ absolute: false
796
+ }
797
+ );
798
+ for (const file of routeModuleFiles) {
799
+ if (parseRouteSlotFile(file)) continue;
800
+ const route = _chunk5QIKR7RRcjs.parseRoutePath.call(void 0, file);
801
+ const pattern = createRoutePattern(route);
802
+ routeModulePatterns.add(pattern);
803
+ if (route.type === "page") {
804
+ patterns.add(pattern);
805
+ }
806
+ }
807
+ }
808
+ for (const route of await _chunkIAMRBF3Zcjs.discoverProgrammaticRoutePaths.call(void 0, source.root, source.srcDir)) {
809
+ patterns.add(route);
810
+ routeModulePatterns.add(route);
811
+ }
812
+ }
813
+ for (const route of extraRoutes) {
814
+ if (route.startsWith("/")) {
815
+ patterns.add(route);
816
+ routeModulePatterns.add(route);
817
+ }
818
+ }
819
+ const sortedPatterns = Array.from(patterns).sort();
820
+ const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
821
+ const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
822
+ const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
823
+ const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
824
+ const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
825
+ const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
826
+ const routeTypesImportPath = `./${path.basename(outPath).replace(/\.d\.ts$/, "")}`;
827
+ const linkAugmentationBlock = suppressLintOnLink ? "" : `
828
+ declare module "@farm.js/core/client" {
829
+ interface LinkDefaultRoute {
830
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
831
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
832
+ }
833
+ }
834
+
835
+ declare module "@farm.js/core" {
836
+ interface LinkDefaultRoute {
837
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
838
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
839
+ }
840
+ // Ensure root import ("@farm.js/core") uses the same typed Link signature as client entry.
841
+ const Link: typeof import("@farm.js/core/client").Link;
842
+ }
843
+
844
+ // Internal declaration path used by @farm.js/core root type re-exports.
845
+ declare module "@farm.js/core/dist/client.js" {
846
+ interface LinkDefaultRoute {
847
+ _: import(${JSON.stringify(routeTypesImportPath)}).RoutePath;
848
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RoutePattern;
849
+ }
850
+ }
851
+ `;
852
+ const routeModuleAugmentationBlock = `
853
+ declare global {
854
+ namespace FarmJS {
855
+ interface RouteRegistry {
856
+ pattern: import(${JSON.stringify(routeTypesImportPath)}).RouteModulePattern;
857
+ }
858
+ }
859
+ }
860
+ `;
861
+ const content = `/**
862
+ * Auto-generated route types from src/app.
863
+ * Link href and route component props are typed automatically from generated declarations.
864
+ * Regenerated on dev start and when routes change.
865
+ * Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
866
+ */
867
+ ${renderTypeAlias("RoutePath", routePathType)}
868
+ ${renderTypeAlias("RoutePattern", routePatternType)}
869
+ ${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentationBlock}${routeModuleAugmentationBlock}
870
+ `;
871
+ return content;
872
+ }
873
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createRouteTypeDeclarations, "createRouteTypeDeclarations");
874
+
875
+ // src/image-types.ts
876
+
877
+
878
+ var FARM_STATIC_IMAGE_EXTENSIONS = ["avif", "gif", "jpeg", "jpg", "png", "webp"];
879
+ function generateFarmImageTypes(options) {
880
+ const outputPath = options.outFile ? path.default.resolve(options.root, options.outFile) : path.default.join(options.root, options.srcDir || "src", "farm-images.d.ts");
881
+ _fs.mkdirSync.call(void 0, path.default.dirname(outputPath), { recursive: true });
882
+ _chunkTIWHTW3Qcjs.writeFileIfChanged.call(void 0, outputPath, createFarmImageTypeDeclarations());
883
+ return outputPath;
884
+ }
885
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmImageTypes, "generateFarmImageTypes");
886
+ function createFarmImageTypeDeclarations() {
887
+ const modules = FARM_STATIC_IMAGE_EXTENSIONS.map(
888
+ (extension) => `declare module "*.${extension}" {
889
+ const image: import("@farm.js/core/image").StaticImageData;
890
+ export const src: string;
891
+ export const width: number;
892
+ export const height: number;
893
+ export const blurDataURL: string | undefined;
894
+ export default image;
895
+ }`
896
+ );
897
+ return `// Generated by Farm.js. Do not edit.
898
+ ${modules.join("\n\n")}
899
+
900
+ declare module "*?url" {
901
+ const src: string;
902
+ export default src;
903
+ }
904
+ `;
905
+ }
906
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmImageTypeDeclarations, "createFarmImageTypeDeclarations");
907
+
908
+ // src/i18n/type-generator.ts
909
+
910
+
911
+ async function generateFarmI18nTypes(options) {
912
+ if (!options.config.enabled) return void 0;
913
+ const { signatures } = await _chunkIQXFRNY2cjs.readFarmI18nCatalogs.call(void 0, options.config);
914
+ const outFile = options.outFile ? _path.resolve.call(void 0, options.root, options.outFile) : _path.join.call(void 0, _path.resolve.call(void 0, options.root), options.srcDir || "src", "farm-i18n.d.ts");
915
+ const content = renderFarmI18nTypes(options.config.locales, signatures);
916
+ _fs.mkdirSync.call(void 0, _path.dirname.call(void 0, outFile), { recursive: true });
917
+ _chunkTIWHTW3Qcjs.writeFileIfChanged.call(void 0, outFile, content);
918
+ return outFile;
919
+ }
920
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmI18nTypes, "generateFarmI18nTypes");
921
+ function renderFarmI18nTypes(locales, signatures) {
922
+ const localeEntries = locales.map((locale) => ` ${JSON.stringify(locale)}: true;`);
923
+ const messageEntries = Object.entries(signatures).sort(([a], [b]) => a.localeCompare(b)).map(([key, signature]) => ` ${JSON.stringify(key)}: ${renderSignature(signature)};`);
924
+ return `// Generated by Farm.js. Do not edit.
925
+ import "@farm.js/core/i18n";
926
+
927
+ declare module "@farm.js/core/i18n" {
928
+ interface FarmI18nLocaleRegistry {
929
+ ${localeEntries.join("\n")}
930
+ }
931
+
932
+ interface FarmI18nMessageRegistry {
933
+ ${messageEntries.join("\n")}
934
+ }
935
+ }
936
+
937
+ export {};
938
+ `;
939
+ }
940
+ _chunkS3JO3N4Hcjs.__name.call(void 0, renderFarmI18nTypes, "renderFarmI18nTypes");
941
+ function renderSignature(signature) {
942
+ const entries = Object.entries(signature).sort(([a], [b]) => a.localeCompare(b));
943
+ if (entries.length === 0) return "Record<never, never>";
944
+ return `{ ${entries.map(([name, kind]) => `${JSON.stringify(name)}: ${argumentType(kind)}`).join("; ")} }`;
945
+ }
946
+ _chunkS3JO3N4Hcjs.__name.call(void 0, renderSignature, "renderSignature");
947
+ function argumentType(kind) {
948
+ switch (kind) {
949
+ case "number":
950
+ return "number";
951
+ case "date":
952
+ return "Date | number";
953
+ case "rich":
954
+ return "(chunks: unknown[]) => unknown";
955
+ case "select":
956
+ case "string":
957
+ return "string";
958
+ }
959
+ }
960
+ _chunkS3JO3N4Hcjs.__name.call(void 0, argumentType, "argumentType");
961
+
962
+ // src/type-artifacts.ts
963
+
964
+
965
+
966
+ // src/content-types.ts
967
+
968
+
969
+ var CONFIG_FILENAMES = [
970
+ "farm.config.ts",
971
+ "farm.config.tsx",
972
+ "farm.config.mts",
973
+ "farm.config.cts",
974
+ "farm.config.js",
975
+ "farm.config.jsx",
976
+ "farm.config.mjs",
977
+ "farm.config.cjs",
978
+ "config.ts",
979
+ "config.tsx",
980
+ "config.mts",
981
+ "config.cts",
982
+ "config.js",
983
+ "config.jsx",
984
+ "config.mjs",
985
+ "config.cjs"
986
+ ];
987
+ function createContentTypeDeclarations(options, outPath) {
988
+ const root = path3.resolve(options.root);
989
+ const projectConfig = findConfigPath(root, options.configPath);
990
+ const configPaths = [
991
+ ...(_nullishCoalesce(options.layerConfigPaths, () => ( []))).filter((value) => fs2.existsSync(value)),
992
+ ...projectConfig ? [projectConfig] : []
993
+ ];
994
+ if (configPaths.length === 0) return createEmptyContentTypes();
995
+ const imports = configPaths.map(
996
+ (configPath, index) => `import type FarmContentConfig${index} from ${JSON.stringify(toTypeImportPath(outPath, configPath))};`
997
+ ).join("\n");
998
+ const registries = configPaths.map(
999
+ (_configPath, index) => `type FarmContentRegistry${index} = ContentRegistryFromConfig<typeof FarmContentConfig${index}>;`
1000
+ ).join("\n");
1001
+ const registryUnion = configPaths.map((_configPath, index) => `FarmContentRegistry${index}`).join(" | ");
1002
+ return `/**
1003
+ * Auto-generated content collection types from Farm layers and farm.config.
1004
+ * Regenerated on dev start, build, and farm generate.
1005
+ */
1006
+ ${imports}
1007
+
1008
+ type FarmContentPluginFromConfig<TConfig> = TConfig extends {
1009
+ plugins?: readonly (infer TPlugin)[];
1010
+ }
1011
+ ? Extract<TPlugin, { readonly __farmContentRegistry: Record<string, unknown> }>
1012
+ : never;
1013
+ type ContentRegistryFromConfig<TConfig> =
1014
+ FarmContentPluginFromConfig<TConfig> extends {
1015
+ readonly __farmContentRegistry: infer TRegistry;
1016
+ }
1017
+ ? TRegistry
1018
+ : never;
1019
+ type FarmContentUnionToIntersection<TValue> = (
1020
+ TValue extends unknown ? (value: TValue) => void : never
1021
+ ) extends (value: infer TIntersection) => void
1022
+ ? TIntersection
1023
+ : never;
1024
+ ${registries}
1025
+
1026
+ type FarmResolvedContentRegistry = [${registryUnion}] extends [never]
1027
+ ? {}
1028
+ : FarmContentUnionToIntersection<${registryUnion}>;
1029
+
1030
+ declare global {
1031
+ namespace FarmJS {
1032
+ interface ContentRegistry {
1033
+ collections: FarmResolvedContentRegistry;
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ export {};
1039
+ `;
1040
+ }
1041
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createContentTypeDeclarations, "createContentTypeDeclarations");
1042
+ function createEmptyContentTypes() {
1043
+ return `/**
1044
+ * Auto-generated content collection types from farm.config.
1045
+ * Regenerated on dev start, build, and farm generate.
1046
+ */
1047
+ declare global {
1048
+ namespace FarmJS {
1049
+ interface ContentRegistry {
1050
+ collections: {};
1051
+ }
1052
+ }
1053
+ }
1054
+
1055
+ export {};
1056
+ `;
1057
+ }
1058
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createEmptyContentTypes, "createEmptyContentTypes");
1059
+ function findConfigPath(root, configPath) {
1060
+ if (configPath) {
1061
+ const resolvedPath = path3.isAbsolute(configPath) ? configPath : path3.join(root, configPath);
1062
+ return fs2.existsSync(resolvedPath) ? resolvedPath : null;
1063
+ }
1064
+ for (const filename of CONFIG_FILENAMES) {
1065
+ const resolvedPath = path3.join(root, filename);
1066
+ if (fs2.existsSync(resolvedPath)) return resolvedPath;
1067
+ }
1068
+ return null;
1069
+ }
1070
+ _chunkS3JO3N4Hcjs.__name.call(void 0, findConfigPath, "findConfigPath");
1071
+ function toTypeImportPath(outPath, targetPath) {
1072
+ const relativePath = path3.relative(path3.dirname(outPath), targetPath).replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
1073
+ return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
1074
+ }
1075
+ _chunkS3JO3N4Hcjs.__name.call(void 0, toTypeImportPath, "toTypeImportPath");
1076
+
1077
+ // src/schema-model-types.ts
1078
+ function createSyncModelTypeDeclarations(plugins) {
1079
+ const rowEntries = [];
1080
+ const insertEntries = [];
1081
+ for (const plugin of _nullishCoalesce(plugins, () => ( []))) {
1082
+ const declaration = _chunkAWRISO2Hcjs.readSchemaTables.call(void 0, plugin);
1083
+ if (!declaration || declaration.name !== "sync") continue;
1084
+ const exposed = declaration.models ? new Set(declaration.models) : null;
1085
+ const models = _chunkJSROZYYOcjs.resolveSchemaModels.call(void 0, declaration.name, declaration.schema);
1086
+ for (const [modelKey, model] of Object.entries(models)) {
1087
+ if (exposed && !exposed.has(modelKey)) continue;
1088
+ if (model.external) continue;
1089
+ rowEntries.push(renderModelEntry(modelKey, model.fields, "row"));
1090
+ insertEntries.push(renderModelEntry(modelKey, model.fields, "insert"));
1091
+ }
1092
+ }
1093
+ if (rowEntries.length === 0) return null;
1094
+ return `/**
1095
+ * Sync model types from the schema passed to sync() in farm.config.
1096
+ * useLiveQuery, useRow, and useSyncAction resolve model names and row
1097
+ * types against these maps. Regenerated when the schema changes.
1098
+ */
1099
+ declare module "@farm.js/sync/client" {
1100
+ interface SyncModels {
1101
+ ${rowEntries.join("\n")}
1102
+ }
1103
+
1104
+ interface SyncModelInputs {
1105
+ ${insertEntries.join("\n")}
1106
+ }
1107
+ }`;
1108
+ }
1109
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createSyncModelTypeDeclarations, "createSyncModelTypeDeclarations");
1110
+ function renderModelEntry(modelKey, fields, shape) {
1111
+ const lines = Object.entries(fields).map(([fieldKey, field]) => {
1112
+ const nullable = field.nullable === true || field.required === false;
1113
+ const optional = shape === "insert" && (nullable || field.primaryKey === true || field.default !== void 0 || isCursorField(fieldKey, field));
1114
+ const type = `${fieldTsType(field)}${nullable ? " | null" : ""}`;
1115
+ return ` ${propertyName(fieldKey)}${optional ? "?" : ""}: ${type};`;
1116
+ });
1117
+ return ` ${propertyName(modelKey)}: {
1118
+ ${lines.join("\n")}
1119
+ };`;
1120
+ }
1121
+ _chunkS3JO3N4Hcjs.__name.call(void 0, renderModelEntry, "renderModelEntry");
1122
+ function fieldTsType(field) {
1123
+ const base = (() => {
1124
+ switch (field.type) {
1125
+ case "boolean":
1126
+ return "boolean";
1127
+ case "integer":
1128
+ case "number":
1129
+ return "number";
1130
+ case "json":
1131
+ return "unknown";
1132
+ case "enum":
1133
+ return _optionalChain([field, 'access', _45 => _45.values, 'optionalAccess', _46 => _46.length]) ? field.values.map((value) => JSON.stringify(value)).join(" | ") : "string";
1134
+ // id, uuid, string, text, datetime all travel as strings over JSON.
1135
+ default:
1136
+ return "string";
1137
+ }
1138
+ })();
1139
+ if (!field.list) return base;
1140
+ return base.includes(" ") ? `(${base})[]` : `${base}[]`;
1141
+ }
1142
+ _chunkS3JO3N4Hcjs.__name.call(void 0, fieldTsType, "fieldTsType");
1143
+ function isCursorField(fieldKey, field) {
1144
+ return field.type === "datetime" && (fieldKey === "updatedAt" || field.name === "updated_at");
1145
+ }
1146
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isCursorField, "isCursorField");
1147
+ function propertyName(key) {
1148
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1149
+ }
1150
+ _chunkS3JO3N4Hcjs.__name.call(void 0, propertyName, "propertyName");
1151
+
1152
+ // src/type-artifacts.ts
1153
+ async function generateFarmTypeArtifacts(options) {
1154
+ const root = _path.resolve.call(void 0, options.root);
1155
+ const srcDir = options.srcDir || "src";
1156
+ const shouldGenerateRoutes = options.routes !== false;
1157
+ const shouldGenerateApi = options.api !== false;
1158
+ const shouldGenerateEnv = options.env !== false;
1159
+ const shouldGenerateImages = options.images !== false;
1160
+ const shouldGenerateI18n = options.i18n !== false && _optionalChain([options, 'access', _47 => _47.i18nConfig, 'optionalAccess', _48 => _48.enabled]);
1161
+ const sourceRoots = _chunkY4YMF2NQcjs.getFarmSourceRoots.call(void 0, { root, srcDir, layers: options.layers });
1162
+ const appDirs = _chunkY4YMF2NQcjs.getFarmAppDirectories.call(void 0, { root, srcDir, layers: options.layers });
1163
+ const result = {
1164
+ apiRoutes: [],
1165
+ stalePaths: []
1166
+ };
1167
+ const unifiedTypesPath = _path.join.call(void 0, root, srcDir, "farm.d.ts");
1168
+ const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
1169
+ const unifiedSections = [];
1170
+ if (shouldRefreshUnifiedTypes && !options.routeTypesOutFile) {
1171
+ const routeOptions = {
1172
+ root,
1173
+ srcDir,
1174
+ extraRoutes: options.extraRoutes || [],
1175
+ suppressLintOnLink: options.suppressLintOnLink,
1176
+ componentExtensions: options.componentExtensions,
1177
+ sourceRoots
1178
+ };
1179
+ unifiedSections.push(await createRouteTypeDeclarations(routeOptions, unifiedTypesPath));
1180
+ result.routeTypesPath = unifiedTypesPath;
1181
+ } else if (shouldGenerateRoutes) {
1182
+ const routeOptions = {
1183
+ root,
1184
+ srcDir,
1185
+ outFile: options.routeTypesOutFile,
1186
+ extraRoutes: options.extraRoutes || [],
1187
+ suppressLintOnLink: options.suppressLintOnLink,
1188
+ componentExtensions: options.componentExtensions,
1189
+ sourceRoots
1190
+ };
1191
+ if (options.check) {
1192
+ const routeTypesPath = resolveGeneratedPath(root, srcDir, options.routeTypesOutFile);
1193
+ const content = await createRouteTypeDeclarations(routeOptions, routeTypesPath);
1194
+ checkGeneratedFile(routeTypesPath, content, result.stalePaths);
1195
+ result.routeTypesPath = routeTypesPath;
1196
+ } else {
1197
+ result.routeTypesPath = await generateRouteTypes(routeOptions);
1198
+ }
1199
+ }
1200
+ if (shouldGenerateApi) {
1201
+ const generator = new (0, _chunkCIAGU2X4cjs.APITypeGenerator)(appDirs);
1202
+ const apiRoutes = generator.scanAPIRoutes();
1203
+ const apiTypesPath = options.apiTypesOutFile ? _path.resolve.call(void 0, root, options.apiTypesOutFile) : _path.join.call(void 0, root, srcDir, "lib", "api.generated.ts");
1204
+ const pluginRoutes = _chunkI4J452B7cjs.resolvePluginRoutes.call(void 0, options.plugins);
1205
+ const configFiles = [
1206
+ ...(_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.configFile).filter((file) => Boolean(file)),
1207
+ options.configPath ? _path.resolve.call(void 0, root, options.configPath) : [
1208
+ "farm.config.ts",
1209
+ "farm.config.mts",
1210
+ "farm.config.js",
1211
+ "farm.config.mjs",
1212
+ "farm.config.cts",
1213
+ "farm.config.cjs",
1214
+ "config.ts",
1215
+ "config.js"
1216
+ ].map((name) => _path.join.call(void 0, root, name)).find((file) => _fs.existsSync.call(void 0, file))
1217
+ ].filter((file) => Boolean(file));
1218
+ if (pluginRoutes.length && !configFiles.length) {
1219
+ throw new Error(
1220
+ "Cannot generate plugin API types without a Farm config file. Pass configPath."
1221
+ );
1222
+ }
1223
+ if (apiRoutes.length > 0 || pluginRoutes.length > 0 || _fs.existsSync.call(void 0, apiTypesPath)) {
1224
+ const content = generator.generateAPIRouter(apiRoutes, {
1225
+ outFile: apiTypesPath,
1226
+ pluginConfigs: pluginRoutes.length ? [...new Set(configFiles)] : [],
1227
+ pluginRoutes
1228
+ });
1229
+ writeOrCheckGeneratedFile(apiTypesPath, content, options.check, result.stalePaths);
1230
+ result.apiTypesPath = apiTypesPath;
1231
+ }
1232
+ result.apiRoutes = apiRoutes;
1233
+ }
1234
+ if (shouldRefreshUnifiedTypes && !options.envTypesOutFile) {
1235
+ unifiedSections.push(
1236
+ _chunk6EODJYCXcjs.createEnvTypeDeclarations.call(void 0,
1237
+ {
1238
+ root,
1239
+ srcDir,
1240
+ configPath: options.configPath,
1241
+ layerConfigPaths: (_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
1242
+ },
1243
+ unifiedTypesPath
1244
+ )
1245
+ );
1246
+ result.envTypesPath = unifiedTypesPath;
1247
+ } else if (shouldGenerateEnv) {
1248
+ const envOptions = {
1249
+ root,
1250
+ srcDir,
1251
+ outFile: options.envTypesOutFile,
1252
+ configPath: options.configPath,
1253
+ layerConfigPaths: (_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
1254
+ };
1255
+ if (options.check) {
1256
+ const envTypesPath = resolveGeneratedPath(root, srcDir, options.envTypesOutFile);
1257
+ checkGeneratedFile(
1258
+ envTypesPath,
1259
+ _chunk6EODJYCXcjs.createEnvTypeDeclarations.call(void 0, envOptions, envTypesPath),
1260
+ result.stalePaths
1261
+ );
1262
+ result.envTypesPath = envTypesPath;
1263
+ } else {
1264
+ result.envTypesPath = await _chunk6EODJYCXcjs.generateEnvTypes.call(void 0, envOptions);
1265
+ }
1266
+ }
1267
+ if (shouldGenerateImages && options.imageTypesOutFile) {
1268
+ const imageTypesPath = resolveGeneratedPath(root, srcDir, options.imageTypesOutFile, false);
1269
+ if (options.check) {
1270
+ checkGeneratedFile(imageTypesPath, createFarmImageTypeDeclarations(), result.stalePaths);
1271
+ result.imageTypesPath = imageTypesPath;
1272
+ } else {
1273
+ result.imageTypesPath = generateFarmImageTypes({
1274
+ root,
1275
+ srcDir,
1276
+ outFile: options.imageTypesOutFile
1277
+ });
1278
+ }
1279
+ }
1280
+ if (shouldRefreshUnifiedTypes && _optionalChain([options, 'access', _49 => _49.i18nConfig, 'optionalAccess', _50 => _50.enabled]) && !options.i18nTypesOutFile) {
1281
+ const { signatures } = await _chunkIQXFRNY2cjs.readFarmI18nCatalogs.call(void 0, options.i18nConfig);
1282
+ unifiedSections.push(renderFarmI18nTypes(options.i18nConfig.locales, signatures));
1283
+ result.i18nTypesPath = unifiedTypesPath;
1284
+ } else if (shouldGenerateI18n && options.i18nConfig) {
1285
+ if (options.check) {
1286
+ const i18nTypesPath = resolveGeneratedPath(root, srcDir, options.i18nTypesOutFile, false);
1287
+ const { signatures } = await _chunkIQXFRNY2cjs.readFarmI18nCatalogs.call(void 0, options.i18nConfig);
1288
+ checkGeneratedFile(
1289
+ i18nTypesPath,
1290
+ renderFarmI18nTypes(options.i18nConfig.locales, signatures),
1291
+ result.stalePaths
1292
+ );
1293
+ result.i18nTypesPath = i18nTypesPath;
1294
+ } else {
1295
+ result.i18nTypesPath = await generateFarmI18nTypes({
1296
+ root,
1297
+ srcDir,
1298
+ config: options.i18nConfig,
1299
+ outFile: options.i18nTypesOutFile
1300
+ });
1301
+ }
1302
+ }
1303
+ if (shouldRefreshUnifiedTypes) {
1304
+ const syncModelTypes = createSyncModelTypeDeclarations(options.plugins);
1305
+ if (syncModelTypes) unifiedSections.push(syncModelTypes);
1306
+ }
1307
+ if (shouldRefreshUnifiedTypes) {
1308
+ unifiedSections.push(
1309
+ createContentTypeDeclarations(
1310
+ {
1311
+ root,
1312
+ configPath: options.configPath,
1313
+ layerConfigPaths: (_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
1314
+ },
1315
+ unifiedTypesPath
1316
+ )
1317
+ );
1318
+ }
1319
+ if (shouldRefreshUnifiedTypes) {
1320
+ writeOrCheckGeneratedFile(
1321
+ unifiedTypesPath,
1322
+ `/**
1323
+ * Generated by Farm.js. Do not edit.
1324
+ * Contains project-specific route, environment, content, and internationalization types.
1325
+ */
1326
+
1327
+ import "@farm.js/core/image";
1328
+ import "@farm.js/core/css";
1329
+
1330
+ ${unifiedSections.map(normalizeUnifiedTypeSection).join("\n\n")}
1331
+ `,
1332
+ options.check,
1333
+ result.stalePaths
1334
+ );
1335
+ result.typesPath = unifiedTypesPath;
1336
+ if (options.check) {
1337
+ collectLegacyTypeArtifacts(root, srcDir, result.stalePaths);
1338
+ } else {
1339
+ removeLegacyTypeArtifacts(root, srcDir);
1340
+ }
1341
+ }
1342
+ return result;
1343
+ }
1344
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmTypeArtifacts, "generateFarmTypeArtifacts");
1345
+ function normalizeUnifiedTypeSection(section) {
1346
+ return section.trimEnd().replace(/\n+export \{\};$/, "");
1347
+ }
1348
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeUnifiedTypeSection, "normalizeUnifiedTypeSection");
1349
+ function resolveGeneratedPath(root, srcDir, outFile, relativeToSrc = true) {
1350
+ if (_path.isAbsolute.call(void 0, outFile)) return _path.resolve.call(void 0, outFile);
1351
+ return _path.resolve.call(void 0, root, relativeToSrc ? _path.join.call(void 0, srcDir, outFile) : outFile);
1352
+ }
1353
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveGeneratedPath, "resolveGeneratedPath");
1354
+ function writeOrCheckGeneratedFile(filePath, content, check, stalePaths) {
1355
+ if (check) {
1356
+ checkGeneratedFile(filePath, content, stalePaths);
1357
+ return;
1358
+ }
1359
+ _fs.mkdirSync.call(void 0, _path.dirname.call(void 0, filePath), { recursive: true });
1360
+ _chunkTIWHTW3Qcjs.writeFileIfChanged.call(void 0, filePath, content);
1361
+ }
1362
+ _chunkS3JO3N4Hcjs.__name.call(void 0, writeOrCheckGeneratedFile, "writeOrCheckGeneratedFile");
1363
+ function checkGeneratedFile(filePath, content, stalePaths) {
1364
+ if (!_fs.existsSync.call(void 0, filePath) || _fs.readFileSync.call(void 0, filePath, "utf8") !== content) {
1365
+ stalePaths.push(filePath);
1366
+ }
1367
+ }
1368
+ _chunkS3JO3N4Hcjs.__name.call(void 0, checkGeneratedFile, "checkGeneratedFile");
1369
+ var LEGACY_TYPE_ARTIFACTS = [
1370
+ ["farm-routes.d.ts", "Auto-generated route types"],
1371
+ ["farm-env.d.ts", "Auto-generated env types"],
1372
+ ["farm-images.d.ts", "Generated by Farm.js"],
1373
+ ["farm-i18n.d.ts", "Generated by Farm.js"]
1374
+ ];
1375
+ function removeLegacyTypeArtifacts(root, srcDir) {
1376
+ for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
1377
+ const filePath = _path.join.call(void 0, root, srcDir, fileName);
1378
+ if (!_fs.existsSync.call(void 0, filePath)) continue;
1379
+ const source = _fs.readFileSync.call(void 0, filePath, "utf8");
1380
+ if (source.includes(marker)) {
1381
+ _fs.unlinkSync.call(void 0, filePath);
1382
+ }
1383
+ }
1384
+ }
1385
+ _chunkS3JO3N4Hcjs.__name.call(void 0, removeLegacyTypeArtifacts, "removeLegacyTypeArtifacts");
1386
+ function collectLegacyTypeArtifacts(root, srcDir, stalePaths) {
1387
+ for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
1388
+ const filePath = _path.join.call(void 0, root, srcDir, fileName);
1389
+ if (!_fs.existsSync.call(void 0, filePath)) continue;
1390
+ if (_fs.readFileSync.call(void 0, filePath, "utf8").includes(marker)) stalePaths.push(filePath);
1391
+ }
1392
+ }
1393
+ _chunkS3JO3N4Hcjs.__name.call(void 0, collectLegacyTypeArtifacts, "collectLegacyTypeArtifacts");
1394
+
1395
+
1396
+
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+
1413
+
1414
+
1415
+ exports.resolveRouteRenderingConfig = resolveRouteRenderingConfig; exports.resolveRouteRenderingConfigFromFile = resolveRouteRenderingConfigFromFile; exports.analyzeStaticRouteCandidate = analyzeStaticRouteCandidate; exports.findRequestBoundSourceBlockers = findRequestBoundSourceBlockers; exports.parseRouteRenderingDirective = parseRouteRenderingDirective; exports.collectSSGPages = collectSSGPages; exports.isSSGModule = isSSGModule; exports.hasISR = hasISR; exports.getRevalidateInterval = getRevalidateInterval; exports.hasPPR = hasPPR; exports.generateSSGManifest = generateSSGManifest; exports.matchSSGPage = matchSSGPage; exports.parseRouteSlotFile = parseRouteSlotFile; exports.createRouteSlotContainerId = createRouteSlotContainerId; exports.generateRouteTypes = generateRouteTypes; exports.generateFarmImageTypes = generateFarmImageTypes; exports.createFarmImageTypeDeclarations = createFarmImageTypeDeclarations; exports.generateFarmI18nTypes = generateFarmI18nTypes; exports.generateFarmTypeArtifacts = generateFarmTypeArtifacts;