@farm.js/core 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/api/route-manager.d.mts +1 -1
- package/dist/api/route-manager.d.ts +1 -1
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api.cjs +2 -2
- package/dist/api.d.mts +18 -4
- package/dist/api.d.ts +18 -4
- package/dist/api.mjs +1 -1
- package/dist/{app-DSSq6wiN.d.mts → app-DAuUTIZf.d.mts} +3 -3
- package/dist/app-markdown.cjs +5 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +4 -3
- package/dist/{app-M8nVWvNU.d.ts → app-sUJ3jnTZ.d.ts} +3 -3
- package/dist/{chunk-N6UROPT7.mjs → chunk-2FQHH5SC.mjs} +12 -13
- package/dist/{chunk-2CNBR3EB.mjs → chunk-2UABTL3Y.mjs} +2 -2
- package/dist/{chunk-JUFRXDTK.cjs → chunk-3FCFQP5V.cjs} +17 -5
- package/dist/{chunk-XSPGWQWA.cjs → chunk-6CNX6Q3K.cjs} +96 -24
- package/dist/{chunk-NVBS5WSZ.mjs → chunk-6G3ZZ2IE.mjs} +1 -1
- package/dist/{chunk-QBPXNZGV.cjs → chunk-6MVFL3R5.cjs} +25 -6
- package/dist/{chunk-PZPDGOU5.mjs → chunk-7CXKSRKL.mjs} +11 -7
- package/dist/{chunk-K3YEZLSY.mjs → chunk-ATXI6LGT.mjs} +96 -24
- package/dist/{chunk-2DLN6HG4.mjs → chunk-BZ3CHOFX.mjs} +1 -1
- package/dist/{chunk-EWZ3XHKQ.cjs → chunk-BZAGKCKB.cjs} +2 -2
- package/dist/{chunk-FB3H4INL.mjs → chunk-D234YWNA.mjs} +1 -1
- package/dist/{chunk-KXGDXYUC.mjs → chunk-DGXN3L4D.mjs} +17 -5
- package/dist/chunk-FJ3M4CUX.cjs +46 -0
- package/dist/chunk-FXEF4PPL.mjs +47 -0
- package/dist/{chunk-ID6OVSLH.cjs → chunk-GIWC4CFJ.cjs} +175 -171
- package/dist/{chunk-F52CDFJM.cjs → chunk-HPQC2LHF.cjs} +435 -274
- package/dist/{chunk-FVCSLZWT.mjs → chunk-IVLUJUT4.mjs} +315 -154
- package/dist/{chunk-KOQ555NR.cjs → chunk-JFHKNFEO.cjs} +24 -20
- package/dist/{chunk-UX2DD2VK.mjs → chunk-K6V52QMI.mjs} +1 -1
- package/dist/{chunk-BYODCJD6.cjs → chunk-K7CELQLK.cjs} +12 -13
- package/dist/{chunk-A672WZEG.cjs → chunk-NPPL5YDT.cjs} +2 -2
- package/dist/{chunk-TII23GJC.cjs → chunk-NXG66MR7.cjs} +3 -3
- package/dist/{chunk-R6AIILII.cjs → chunk-OZVEHHMA.cjs} +15 -14
- package/dist/{chunk-T7HQ3I4C.mjs → chunk-PQD2AI3B.mjs} +1 -1
- package/dist/{chunk-VQXDC5UV.cjs → chunk-Q5JFU33Q.cjs} +4 -4
- package/dist/{chunk-FZC7EEPM.mjs → chunk-RSOJ7DRT.mjs} +26 -7
- package/dist/{chunk-ZRIE4KMG.mjs → chunk-S4K74WI4.mjs} +17 -13
- package/dist/{chunk-Y7GW7J46.cjs → chunk-X5TXZFMN.cjs} +1 -1
- package/dist/chunk-XD32KALF.cjs +47 -0
- package/dist/{chunk-RDV44SED.mjs → chunk-XJJVLDM6.mjs} +15 -14
- package/dist/{chunk-55ZY4ZA7.cjs → chunk-XLTV4VOG.cjs} +21 -16
- package/dist/{chunk-REGFZJEJ.mjs → chunk-YMUE7L3D.mjs} +18 -13
- package/dist/chunk-Z3HATSKO.mjs +46 -0
- package/dist/{chunk-MH24QDVJ.cjs → chunk-ZDILFMWN.cjs} +13 -13
- package/dist/{client-plugins-CgYNY7jF.d.mts → client-plugins-BX2ptm4H.d.mts} +7 -2
- package/dist/{client-plugins-Fl9Og3yB.d.ts → client-plugins-BmxM5KW_.d.ts} +7 -2
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/{devtools-5AREISIA.cjs → devtools-GGVPZHJX.cjs} +95 -20
- package/dist/{devtools-3E7ZANMZ.mjs → devtools-THVNPI2M.mjs} +79 -4
- package/dist/{devtools-client-4WAPJY5L.cjs → devtools-client-CXQ6PXI6.cjs} +1 -1
- package/dist/{devtools-client-LEUIHHAS.mjs → devtools-client-HJS2T34Y.mjs} +1 -1
- package/dist/docs.cjs +8 -7
- package/dist/docs.mjs +7 -6
- package/dist/index.cjs +18 -16
- package/dist/index.d.mts +24 -14
- package/dist/index.d.ts +24 -14
- package/dist/index.mjs +17 -15
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.cjs +4 -3
- package/dist/internal/app-markdown-runtime.d.mts +3 -3
- package/dist/internal/app-markdown-runtime.d.ts +3 -3
- package/dist/internal/app-markdown-runtime.mjs +3 -2
- package/dist/internal/build-runtime.cjs +15 -13
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +14 -12
- package/dist/internal/cli-runtime.cjs +7 -6
- package/dist/internal/cli-runtime.mjs +6 -5
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.cjs +3 -2
- package/dist/internal/compression-runtime.d.mts +5 -3
- package/dist/internal/compression-runtime.d.ts +5 -3
- package/dist/internal/compression-runtime.mjs +2 -1
- package/dist/internal/config-runtime.cjs +6 -5
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/product-telemetry-runtime.cjs +10 -6
- package/dist/internal/product-telemetry-runtime.mjs +9 -5
- package/dist/internal/production-runtime.cjs +19 -5
- package/dist/internal/production-runtime.d.mts +35 -8
- package/dist/internal/production-runtime.d.ts +35 -8
- package/dist/internal/production-runtime.mjs +18 -4
- package/dist/markdown.cjs +3 -2
- package/dist/markdown.d.mts +2 -2
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.mjs +2 -1
- package/dist/{metadata-B0X-qtcQ.d.mts → metadata-DsEaK7mQ.d.mts} +1 -1
- package/dist/{metadata-BdDKgd7K.d.ts → metadata-fwZ3gfG6.d.ts} +1 -1
- package/dist/middleware.cjs +3 -2
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +2 -1
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/plugin.cjs +10 -9
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.mjs +9 -8
- package/dist/{production-runtime-BjgFgDIg.d.mts → production-runtime-Baqgwtvc.d.mts} +1 -1
- package/dist/{production-runtime-Dx_qMA3t.d.ts → production-runtime-DNkpFnmg.d.ts} +1 -1
- package/dist/{render-plan-_1TAWODt.d.mts → render-plan-DhwQnmmX.d.mts} +1 -1
- package/dist/{render-plan-B41EWmBb.d.ts → render-plan-rkIK9wd9.d.ts} +1 -1
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/{request-Dbf3G0zM.d.ts → request-BcY4RYPC.d.ts} +1 -1
- package/dist/{request-BhE4luLv.d.mts → request-CFy1BltJ.d.mts} +1 -1
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/{route-rendering-zzfx_GHf.d.mts → route-rendering-BkS0TBlB.d.mts} +1 -1
- package/dist/{route-rendering-Z7PveTZE.d.ts → route-rendering-D4XpMjam.d.ts} +1 -1
- package/dist/{router-BatNMsa1.d.mts → router-C4zPlC3V.d.mts} +1 -1
- package/dist/{router-DtNRhQl3.d.ts → router-Cq7BcZxg.d.ts} +1 -1
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/server-plugins.cjs +3 -2
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +2 -1
- package/dist/server.cjs +33 -28
- package/dist/server.d.mts +8 -8
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +16 -11
- package/dist/{spa-router-BE3bwU-J.d.ts → spa-router-B1HI3X9k.d.ts} +2 -2
- package/dist/{spa-router-DQOnHZVj.d.mts → spa-router-DzPZH-AO.d.mts} +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{utils-DLK1ERNl.d.mts → utils-CEBktlBG.d.mts} +1 -1
- package/dist/{utils-u7ZBSWAK.d.ts → utils-DMD1Hzta.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +10 -9
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +9 -8
- package/package.json +1 -1
|
@@ -6,10 +6,11 @@ var _chunkA6WIQH5Zcjs = require('./chunk-A6WIQH5Z.cjs');
|
|
|
6
6
|
var _chunkMT763TDWcjs = require('./chunk-MT763TDW.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunkXD32KALFcjs = require('./chunk-XD32KALF.cjs');
|
|
9
10
|
|
|
10
|
-
var _chunkMH24QDVJcjs = require('./chunk-MH24QDVJ.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
var _chunkZDILFMWNcjs = require('./chunk-ZDILFMWN.cjs');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
@@ -17,7 +18,9 @@ var _chunkMH24QDVJcjs = require('./chunk-MH24QDVJ.cjs');
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkQ5JFU33Qcjs = require('./chunk-Q5JFU33Q.cjs');
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
|
|
@@ -34,7 +37,7 @@ var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
|
|
|
34
37
|
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
var
|
|
40
|
+
var _chunkJFHKNFEOcjs = require('./chunk-JFHKNFEO.cjs');
|
|
38
41
|
|
|
39
42
|
|
|
40
43
|
var _chunkKCMTCM6Icjs = require('./chunk-KCMTCM6I.cjs');
|
|
@@ -70,7 +73,7 @@ var _chunk2SJ4RQ6Pcjs = require('./chunk-2SJ4RQ6P.cjs');
|
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
|
|
73
|
-
var
|
|
76
|
+
var _chunkGIWC4CFJcjs = require('./chunk-GIWC4CFJ.cjs');
|
|
74
77
|
|
|
75
78
|
|
|
76
79
|
|
|
@@ -80,7 +83,7 @@ var _chunkCTV2TTNPcjs = require('./chunk-CTV2TTNP.cjs');
|
|
|
80
83
|
|
|
81
84
|
|
|
82
85
|
|
|
83
|
-
var
|
|
86
|
+
var _chunkNPPL5YDTcjs = require('./chunk-NPPL5YDT.cjs');
|
|
84
87
|
|
|
85
88
|
|
|
86
89
|
var _chunkCXP5U3RWcjs = require('./chunk-CXP5U3RW.cjs');
|
|
@@ -112,7 +115,7 @@ var _chunkVPTDD5XFcjs = require('./chunk-VPTDD5XF.cjs');
|
|
|
112
115
|
var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
|
|
113
116
|
|
|
114
117
|
|
|
115
|
-
var
|
|
118
|
+
var _chunkXLTV4VOGcjs = require('./chunk-XLTV4VOG.cjs');
|
|
116
119
|
|
|
117
120
|
|
|
118
121
|
|
|
@@ -124,14 +127,14 @@ var _chunk6EXBPJ24cjs = require('./chunk-6EXBPJ24.cjs');
|
|
|
124
127
|
var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
|
|
125
128
|
|
|
126
129
|
|
|
127
|
-
var
|
|
130
|
+
var _chunkNXG66MR7cjs = require('./chunk-NXG66MR7.cjs');
|
|
128
131
|
|
|
129
132
|
|
|
130
133
|
|
|
131
134
|
var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
|
|
132
135
|
|
|
133
136
|
|
|
134
|
-
var
|
|
137
|
+
var _chunk6CNX6Q3Kcjs = require('./chunk-6CNX6Q3K.cjs');
|
|
135
138
|
|
|
136
139
|
|
|
137
140
|
|
|
@@ -279,7 +282,7 @@ function getDocsTitle(docs) {
|
|
|
279
282
|
}
|
|
280
283
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getDocsTitle, "getDocsTitle");
|
|
281
284
|
function loadPages(contentDir, docs) {
|
|
282
|
-
return
|
|
285
|
+
return _chunkQ5JFU33Qcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkQ5JFU33Qcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
|
|
283
286
|
}
|
|
284
287
|
_chunkS3JO3N4Hcjs.__name.call(void 0, loadPages, "loadPages");
|
|
285
288
|
function findSocialImagePath(html) {
|
|
@@ -300,14 +303,14 @@ async function addHandlerRoute(routes, pathname, handler, absolutePaths) {
|
|
|
300
303
|
}
|
|
301
304
|
_chunkS3JO3N4Hcjs.__name.call(void 0, addHandlerRoute, "addHandlerRoute");
|
|
302
305
|
async function compileFarmDocsManifest(docs, options) {
|
|
303
|
-
const contentDir =
|
|
306
|
+
const contentDir = _chunkQ5JFU33Qcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
|
|
304
307
|
const pages = loadPages(contentDir, docs);
|
|
305
308
|
const absolutePaths = [
|
|
306
309
|
_path2.default.resolve(options.root),
|
|
307
310
|
_path2.default.resolve(contentDir),
|
|
308
311
|
docs.configPath || ""
|
|
309
312
|
];
|
|
310
|
-
const handler =
|
|
313
|
+
const handler = _chunkQ5JFU33Qcjs.createFarmDocsHandler.call(void 0, docs, {
|
|
311
314
|
root: options.root,
|
|
312
315
|
srcDir: options.srcDir,
|
|
313
316
|
clientEntry: options.clientEntry,
|
|
@@ -315,7 +318,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
315
318
|
fontStylesheetHref: options.fontStylesheetHref,
|
|
316
319
|
globalStylesheetHref: options.globalStylesheetHref
|
|
317
320
|
});
|
|
318
|
-
const apiHandler =
|
|
321
|
+
const apiHandler = _chunkZDILFMWNcjs.createFarmDocsAPIHandler.call(void 0, {
|
|
319
322
|
rootDir: options.root,
|
|
320
323
|
srcDir: options.srcDir,
|
|
321
324
|
docs
|
|
@@ -407,7 +410,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
407
410
|
post: await compileResponse(postResponse, absolutePaths),
|
|
408
411
|
search: {
|
|
409
412
|
pages: pages.map((page) => ({
|
|
410
|
-
...
|
|
413
|
+
..._chunkQ5JFU33Qcjs.toFarmDocsMarkdownPage.call(void 0, page),
|
|
411
414
|
sourcePath: `farm-docs:${page.slug || "index"}`
|
|
412
415
|
})),
|
|
413
416
|
search: _nullishCoalesce(searchConfig, () => ( true)),
|
|
@@ -1256,6 +1259,19 @@ function isNitroRollupExternal(id) {
|
|
|
1256
1259
|
}
|
|
1257
1260
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isNitroRollupExternal, "isNitroRollupExternal");
|
|
1258
1261
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
1262
|
+
function createReactProductionModePlugin() {
|
|
1263
|
+
const nodeEnvExpression = ["process", "env", "NODE_ENV"].join(".");
|
|
1264
|
+
return {
|
|
1265
|
+
name: "farm-react-production-mode",
|
|
1266
|
+
transform(code, id) {
|
|
1267
|
+
const normalizedId = id.replace(/\\/g, "/");
|
|
1268
|
+
const isReactRuntime = normalizedId.includes("/node_modules/react/") || normalizedId.includes("/node_modules/react-dom/");
|
|
1269
|
+
if (!isReactRuntime || !code.includes(nodeEnvExpression)) return null;
|
|
1270
|
+
return { code: code.split(nodeEnvExpression).join('"production"'), map: null };
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createReactProductionModePlugin, "createReactProductionModePlugin");
|
|
1259
1275
|
function createMetadataImageWasmPlugin() {
|
|
1260
1276
|
return {
|
|
1261
1277
|
name: "farm-metadata-image-wasm",
|
|
@@ -1350,42 +1366,75 @@ async function minifyFarmServerChunk(code, fileName, options) {
|
|
|
1350
1366
|
}
|
|
1351
1367
|
_chunkS3JO3N4Hcjs.__name.call(void 0, minifyFarmServerChunk, "minifyFarmServerChunk");
|
|
1352
1368
|
function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor }) {
|
|
1353
|
-
|
|
1369
|
+
const hasImportTemplate = code.includes("import(`");
|
|
1370
|
+
const hasRequireTemplate = code.includes("require(`");
|
|
1371
|
+
if (!hasImportTemplate && !hasRequireTemplate) return code;
|
|
1354
1372
|
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
1355
1373
|
if (parsed.errors.length > 0) {
|
|
1356
1374
|
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
1357
1375
|
}
|
|
1358
1376
|
const replacements = [];
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
ImportExpression(node) {
|
|
1372
|
-
restore(node.source);
|
|
1373
|
-
},
|
|
1374
|
-
CallExpression(node) {
|
|
1375
|
-
if (node.callee.type === "Identifier" && node.callee.name === "require" && node.arguments.length === 1) {
|
|
1376
|
-
restore(node.arguments[0]);
|
|
1377
|
+
let needsAst = hasRequireTemplate;
|
|
1378
|
+
if (!needsAst) {
|
|
1379
|
+
const seenStarts = /* @__PURE__ */ new Set();
|
|
1380
|
+
for (const { moduleRequest } of parsed.module.dynamicImports) {
|
|
1381
|
+
if (seenStarts.has(moduleRequest.start)) continue;
|
|
1382
|
+
seenStarts.add(moduleRequest.start);
|
|
1383
|
+
const source = code.slice(moduleRequest.start, moduleRequest.end);
|
|
1384
|
+
if (!source.startsWith("`")) continue;
|
|
1385
|
+
const value = source.slice(1, -1);
|
|
1386
|
+
if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
|
|
1387
|
+
needsAst = true;
|
|
1388
|
+
break;
|
|
1377
1389
|
}
|
|
1390
|
+
replacements.push({
|
|
1391
|
+
start: moduleRequest.start,
|
|
1392
|
+
end: moduleRequest.end,
|
|
1393
|
+
text: toAsciiStringLiteral(value)
|
|
1394
|
+
});
|
|
1378
1395
|
}
|
|
1379
|
-
}
|
|
1396
|
+
}
|
|
1397
|
+
if (needsAst) {
|
|
1398
|
+
replacements.length = 0;
|
|
1399
|
+
const restore = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (node) => {
|
|
1400
|
+
if (_optionalChain([node, 'optionalAccess', _17 => _17.type]) !== "TemplateLiteral") return;
|
|
1401
|
+
const template = node;
|
|
1402
|
+
const value = _optionalChain([template, 'access', _18 => _18.quasis, 'access', _19 => _19[0], 'optionalAccess', _20 => _20.value, 'access', _21 => _21.cooked]);
|
|
1403
|
+
if (template.expressions.length > 0 || typeof value !== "string") return;
|
|
1404
|
+
replacements.push({
|
|
1405
|
+
start: template.start,
|
|
1406
|
+
end: template.end,
|
|
1407
|
+
text: toAsciiStringLiteral(value)
|
|
1408
|
+
});
|
|
1409
|
+
}, "restore");
|
|
1410
|
+
new Visitor({
|
|
1411
|
+
ImportExpression(node) {
|
|
1412
|
+
restore(node.source);
|
|
1413
|
+
},
|
|
1414
|
+
CallExpression(node) {
|
|
1415
|
+
if (node.callee.type === "Identifier" && node.callee.name === "require" && node.arguments.length === 1) {
|
|
1416
|
+
restore(node.arguments[0]);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}).visit(parsed.program);
|
|
1420
|
+
}
|
|
1380
1421
|
let restored = "";
|
|
1381
1422
|
let offset = 0;
|
|
1382
1423
|
for (const { start, end, text } of replacements.sort((a, b) => a.start - b.start)) {
|
|
1424
|
+
if (start < offset) continue;
|
|
1383
1425
|
restored += code.slice(offset, start) + text;
|
|
1384
1426
|
offset = end;
|
|
1385
1427
|
}
|
|
1386
1428
|
return restored + code.slice(offset);
|
|
1387
1429
|
}
|
|
1388
1430
|
_chunkS3JO3N4Hcjs.__name.call(void 0, restoreLiteralModuleSpecifiers, "restoreLiteralModuleSpecifiers");
|
|
1431
|
+
function toAsciiStringLiteral(value) {
|
|
1432
|
+
return JSON.stringify(value).replace(
|
|
1433
|
+
/[\u007f-]/g,
|
|
1434
|
+
(character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toAsciiStringLiteral, "toAsciiStringLiteral");
|
|
1389
1438
|
function createServerChunkMinifyPlugin(options) {
|
|
1390
1439
|
return {
|
|
1391
1440
|
name: "farm-server-chunk-minify",
|
|
@@ -1487,7 +1536,7 @@ function hasFarmPluginRoutes(config) {
|
|
|
1487
1536
|
_chunkS3JO3N4Hcjs.__name.call(void 0, hasFarmPluginRoutes, "hasFarmPluginRoutes");
|
|
1488
1537
|
function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
1489
1538
|
return (config.plugins || []).some(
|
|
1490
|
-
(plugin) => _chunkZ5HIWVDPcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false &&
|
|
1539
|
+
(plugin) => _chunkZ5HIWVDPcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && _chunkGIWC4CFJcjs.farmPluginMayAffectRuntimePath.call(void 0, plugin, pathname)
|
|
1491
1540
|
);
|
|
1492
1541
|
}
|
|
1493
1542
|
_chunkS3JO3N4Hcjs.__name.call(void 0, farmServerRuntimePluginsMayHandlePath, "farmServerRuntimePluginsMayHandlePath");
|
|
@@ -1549,7 +1598,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1549
1598
|
assertFarmDocsRuntimeSupported(config, preset);
|
|
1550
1599
|
const srcDir = config.srcDir || "src";
|
|
1551
1600
|
const distDir = config.distDir || ".farm";
|
|
1552
|
-
const deployOutputDir =
|
|
1601
|
+
const deployOutputDir = _chunkJFHKNFEOcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
1553
1602
|
const lifecyclePluginManager = options.pluginManager;
|
|
1554
1603
|
const productionViteResultPromise = Promise.allSettled([
|
|
1555
1604
|
Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))
|
|
@@ -1568,7 +1617,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1568
1617
|
const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
|
|
1569
1618
|
const pageRoutes = [];
|
|
1570
1619
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
1571
|
-
const markdownSourcePath = entry.markdownSourcePath || (
|
|
1620
|
+
const markdownSourcePath = entry.markdownSourcePath || (_chunkNXG66MR7cjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
|
|
1572
1621
|
pageRoutes.push({
|
|
1573
1622
|
pattern,
|
|
1574
1623
|
modulePath: entry.modulePath,
|
|
@@ -1797,7 +1846,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
1797
1846
|
}
|
|
1798
1847
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
1799
1848
|
await fs.writeFile(fontCssPath, normalizedFontCss);
|
|
1800
|
-
await fs.writeFile(clientCssPath,
|
|
1849
|
+
await fs.writeFile(clientCssPath, _chunkGIWC4CFJcjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
|
|
1801
1850
|
}
|
|
1802
1851
|
_chunkS3JO3N4Hcjs.__name.call(void 0, mergeBuiltFontCss, "mergeBuiltFontCss");
|
|
1803
1852
|
var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
|
|
@@ -1847,7 +1896,7 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
1847
1896
|
const key = `${_path2.default.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${_path2.default.resolve(modulePath)}`;
|
|
1848
1897
|
let plan = cache.get(key);
|
|
1849
1898
|
if (!plan) {
|
|
1850
|
-
plan =
|
|
1899
|
+
plan = _chunkGIWC4CFJcjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
|
|
1851
1900
|
cache.set(key, plan);
|
|
1852
1901
|
}
|
|
1853
1902
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
@@ -1876,14 +1925,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
1876
1925
|
`[Farm.js] isolated hydration kept route-wide because integration provider "${unsupportedIntegrationProvider.name}" does not declare supportsIsolatedHydration: true.`
|
|
1877
1926
|
);
|
|
1878
1927
|
}
|
|
1879
|
-
const isolatedMode =
|
|
1928
|
+
const isolatedMode = _chunkGIWC4CFJcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
|
|
1880
1929
|
_optionalChain([config, 'access', _35 => _35.experimental, 'optionalAccess', _36 => _36.isolatedClientHydration]),
|
|
1881
1930
|
{
|
|
1882
1931
|
serverComponents: _optionalChain([config, 'access', _37 => _37.experimental, 'optionalAccess', _38 => _38.serverComponents]) === true,
|
|
1883
1932
|
hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
|
|
1884
1933
|
}
|
|
1885
1934
|
);
|
|
1886
|
-
const planOptions =
|
|
1935
|
+
const planOptions = _chunkGIWC4CFJcjs.getFarmClientHydrationPlanOptions.call(void 0,
|
|
1887
1936
|
config.renderer,
|
|
1888
1937
|
Boolean(unsupportedIntegrationProvider)
|
|
1889
1938
|
);
|
|
@@ -1940,7 +1989,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
1940
1989
|
), "isAdapterDocsRoute");
|
|
1941
1990
|
const syntheticDocsEntry = _optionalChain([config, 'access', _46 => _46.docs, 'optionalAccess', _47 => _47.enabled]) && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
|
|
1942
1991
|
const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
|
|
1943
|
-
const markdownPagePlan =
|
|
1992
|
+
const markdownPagePlan = _chunkGIWC4CFJcjs.createMarkdownPageHydrationPlanner.call(void 0,
|
|
1944
1993
|
_chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), root),
|
|
1945
1994
|
root,
|
|
1946
1995
|
isolatedMode,
|
|
@@ -1948,7 +1997,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
1948
1997
|
);
|
|
1949
1998
|
const routePlans = pageRoutes.map((route) => ({
|
|
1950
1999
|
route,
|
|
1951
|
-
metadata:
|
|
2000
|
+
metadata: _chunkNXG66MR7cjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
1952
2001
|
route.modulePath,
|
|
1953
2002
|
root,
|
|
1954
2003
|
isolatedMode,
|
|
@@ -1956,7 +2005,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
1956
2005
|
planOptions
|
|
1957
2006
|
)
|
|
1958
2007
|
}));
|
|
1959
|
-
|
|
2008
|
+
_chunkGIWC4CFJcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
|
|
1960
2009
|
clientLayouts.map((layout) => ({
|
|
1961
2010
|
pattern: layout.pattern,
|
|
1962
2011
|
depth: layout.pattern.split("/").filter(Boolean).length,
|
|
@@ -1988,7 +2037,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
1988
2037
|
for (const layout of clientLayouts) {
|
|
1989
2038
|
const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, route.pattern)) || Boolean(adapterDocsEntry && layoutAppliesToRoute(layout.pattern, adapterDocsEntry));
|
|
1990
2039
|
if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
|
|
1991
|
-
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${
|
|
2040
|
+
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${_chunkGIWC4CFJcjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`);
|
|
1992
2041
|
}
|
|
1993
2042
|
}
|
|
1994
2043
|
if (isolatedMode === "analyze") {
|
|
@@ -2012,7 +2061,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2012
2061
|
);
|
|
2013
2062
|
if (metadata.suppressedAsyncHydration) {
|
|
2014
2063
|
_chunk5QIKR7RRcjs.logger.warn(
|
|
2015
|
-
`\u26A0\uFE0F ${
|
|
2064
|
+
`\u26A0\uFE0F ${_chunkGIWC4CFJcjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
|
|
2016
2065
|
);
|
|
2017
2066
|
}
|
|
2018
2067
|
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0) {
|
|
@@ -2071,7 +2120,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2071
2120
|
}
|
|
2072
2121
|
const clientRouteSlots = routeSlots.filter((slot) => {
|
|
2073
2122
|
try {
|
|
2074
|
-
return
|
|
2123
|
+
return _chunkGIWC4CFJcjs.getClientModuleMetadata.call(void 0, slot.modulePath, root).shouldHydrate;
|
|
2075
2124
|
} catch (error) {
|
|
2076
2125
|
_chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
|
|
2077
2126
|
return false;
|
|
@@ -2101,7 +2150,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2101
2150
|
config.trailingSlash,
|
|
2102
2151
|
_chunkZ5HIWVDPcjs.getIntegrationProviders.call(void 0, config.integrations),
|
|
2103
2152
|
config.basePath,
|
|
2104
|
-
|
|
2153
|
+
_chunkGIWC4CFJcjs.generateClientCachePersistenceCode.call(void 0, _chunkGIWC4CFJcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
|
|
2105
2154
|
adapterOwnsDocsRuntime ? _chunk75WGQVQAcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
|
|
2106
2155
|
);
|
|
2107
2156
|
await fs.writeFile(clientEntryPath, clientHydrationCode);
|
|
@@ -2118,7 +2167,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2118
2167
|
const postcssConfigPath = _path2.default.join(clientEntryDir, "postcss.config.cjs");
|
|
2119
2168
|
await fs.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2120
2169
|
postcssSearchPath = clientEntryDir;
|
|
2121
|
-
tailwindVitePlugin = await
|
|
2170
|
+
tailwindVitePlugin = await _chunkGIWC4CFJcjs.loadTailwindVitePlugin.call(void 0, {
|
|
2122
2171
|
builder: productionVite.builder,
|
|
2123
2172
|
announce: true
|
|
2124
2173
|
});
|
|
@@ -2187,7 +2236,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2187
2236
|
}
|
|
2188
2237
|
},
|
|
2189
2238
|
plugins: [
|
|
2190
|
-
|
|
2239
|
+
_chunkGIWC4CFJcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
|
|
2191
2240
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
2192
2241
|
...rendererVitePlugins,
|
|
2193
2242
|
...config.vite.plugins || [],
|
|
@@ -2248,7 +2297,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2248
2297
|
} : void 0,
|
|
2249
2298
|
// Ensure React is bundled for client
|
|
2250
2299
|
resolve: {
|
|
2251
|
-
alias:
|
|
2300
|
+
alias: _chunkGIWC4CFJcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
|
|
2252
2301
|
dedupe: [...config.renderer.dedupe || []]
|
|
2253
2302
|
},
|
|
2254
2303
|
// Optimize dependencies - exclude server-side code from client bundle
|
|
@@ -2261,7 +2310,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2261
2310
|
]
|
|
2262
2311
|
}
|
|
2263
2312
|
};
|
|
2264
|
-
await viteBuild(
|
|
2313
|
+
await viteBuild(_chunkGIWC4CFJcjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite));
|
|
2265
2314
|
await mergeBuiltFontCss(outputDir);
|
|
2266
2315
|
await validateClientBuildOutput(root, srcDir, outputDir);
|
|
2267
2316
|
} finally {
|
|
@@ -3020,7 +3069,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
3020
3069
|
direction: {}
|
|
3021
3070
|
}, plugins = [], renderer = _chunkPSV6XKPOcjs.REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule) {
|
|
3022
3071
|
const toImportPath = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (targetPath) => targetPath.replace(/\\/g, "/"), "toImportPath");
|
|
3023
|
-
const clientPluginEntry =
|
|
3072
|
+
const clientPluginEntry = _chunkGIWC4CFJcjs.generateFarmClientPluginEntryCode.call(void 0,
|
|
3024
3073
|
plugins,
|
|
3025
3074
|
root,
|
|
3026
3075
|
srcDir,
|
|
@@ -3031,7 +3080,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
3031
3080
|
import { createRoot, hydrateRoot } from "react-dom/client";` : appSetupPath ? `import React, { createRoot, hydrateRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)};
|
|
3032
3081
|
import __farmAppSetup from ${JSON.stringify(_chunk5QIKR7RRcjs.toPosixPath.call(void 0, appSetupPath))};
|
|
3033
3082
|
__farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
|
|
3034
|
-
const providerClientCode =
|
|
3083
|
+
const providerClientCode = _chunkGIWC4CFJcjs.generateFarmIntegrationProviderClientCode.call(void 0,
|
|
3035
3084
|
integrationProviders,
|
|
3036
3085
|
root,
|
|
3037
3086
|
_nullishCoalesce(renderer.componentExtensions, () => ( []))
|
|
@@ -3516,7 +3565,7 @@ function hasHydratableLayout(pathname) {
|
|
|
3516
3565
|
});
|
|
3517
3566
|
}
|
|
3518
3567
|
|
|
3519
|
-
${
|
|
3568
|
+
${_chunkGIWC4CFJcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
|
|
3520
3569
|
// Wrap a page element with applicable layouts
|
|
3521
3570
|
function wrapWithLayouts(pageElement, pathname, params) {
|
|
3522
3571
|
const layouts = getApplicableLayouts(pathname);
|
|
@@ -4431,7 +4480,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4431
4480
|
_path2.default.join(postcssConfigDir, "postcss.config.cjs"),
|
|
4432
4481
|
"module.exports = { plugins: [] };\n"
|
|
4433
4482
|
);
|
|
4434
|
-
tailwindVitePlugin = await
|
|
4483
|
+
tailwindVitePlugin = await _chunkGIWC4CFJcjs.loadTailwindVitePlugin.call(void 0, {
|
|
4435
4484
|
builder: productionVite.builder,
|
|
4436
4485
|
label: "for SSR"
|
|
4437
4486
|
});
|
|
@@ -4527,7 +4576,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4527
4576
|
}
|
|
4528
4577
|
const middlewareRoutes = await discoverMiddlewareRoutes(appDirs);
|
|
4529
4578
|
const instrumentationPath = _chunkKCMTCM6Icjs.resolveFarmInstrumentationFile.call(void 0, root, config.srcDir || "src");
|
|
4530
|
-
const notFoundPath =
|
|
4579
|
+
const notFoundPath = _chunkGIWC4CFJcjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
|
|
4531
4580
|
if (notFoundPath) _chunk5QIKR7RRcjs.logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
|
|
4532
4581
|
layoutRoutes.sort((a, b) => {
|
|
4533
4582
|
const depthA = a.pattern.split("/").filter(Boolean).length;
|
|
@@ -4550,7 +4599,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4550
4599
|
const hasObservabilityHandler = !!config.observability && typeof config.observability === "object" && "onEvent" in config.observability;
|
|
4551
4600
|
const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access', _56 => _56.mdx, 'optionalAccess', _57 => _57.components]));
|
|
4552
4601
|
const hasMiddlewareConfig = hasFarmMiddlewareConfig(config.middleware);
|
|
4553
|
-
const hasRouteContextConfig =
|
|
4602
|
+
const hasRouteContextConfig = _chunkJFHKNFEOcjs.hasCustomFarmRouteContext.call(void 0, config);
|
|
4554
4603
|
const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
|
|
4555
4604
|
const hasPluginRoutes = hasFarmPluginRoutes(config);
|
|
4556
4605
|
const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
|
|
@@ -4559,7 +4608,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4559
4608
|
const hasConfiguredRuntimePlugins = Boolean(
|
|
4560
4609
|
hasRuntimeConfigModule && (config.plugins || []).length > 0
|
|
4561
4610
|
);
|
|
4562
|
-
const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _58 => _58.docs, 'optionalAccess', _59 => _59.enabled]) && _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? _optionalChain([config, 'access', _60 => _60.docs, 'access', _61 => _61.adapter, 'optionalAccess', _62 => _62.server]) ? await
|
|
4611
|
+
const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _58 => _58.docs, 'optionalAccess', _59 => _59.enabled]) && _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? _optionalChain([config, 'access', _60 => _60.docs, 'access', _61 => _61.adapter, 'optionalAccess', _62 => _62.server]) ? await _chunkZDILFMWNcjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
|
|
4563
4612
|
root,
|
|
4564
4613
|
srcDir: config.srcDir,
|
|
4565
4614
|
clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
|
|
@@ -4709,25 +4758,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4709
4758
|
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _68 => _68.env, 'optionalAccess', _69 => _69.public]) || {})
|
|
4710
4759
|
},
|
|
4711
4760
|
plugins: [
|
|
4712
|
-
|
|
4761
|
+
_chunkGIWC4CFJcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
|
|
4713
4762
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
4714
4763
|
...rendererVitePlugins,
|
|
4715
4764
|
...config.vite.plugins || [],
|
|
4716
4765
|
...!useExternalMetadataImageRuntime && metadataImageRoutes.some((image) => image.sourceType === "module") ? [createMetadataImageWasmPlugin()] : [],
|
|
4717
|
-
{
|
|
4718
|
-
name: "farm-react-production-mode",
|
|
4719
|
-
enforce: "pre",
|
|
4720
|
-
transform(code, id) {
|
|
4721
|
-
const normalizedId = id.replace(/\\/g, "/");
|
|
4722
|
-
const isReactRuntime = normalizedId.includes("/node_modules/react/") || normalizedId.includes("/node_modules/react-dom/");
|
|
4723
|
-
const nodeEnvExpression = ["process", "env", "NODE_ENV"].join(".");
|
|
4724
|
-
if (!isReactRuntime || !code.includes(nodeEnvExpression)) return null;
|
|
4725
|
-
return {
|
|
4726
|
-
code: code.split(nodeEnvExpression).join('"production"'),
|
|
4727
|
-
map: null
|
|
4728
|
-
};
|
|
4729
|
-
}
|
|
4730
|
-
},
|
|
4766
|
+
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
4731
4767
|
farmServerOnlyEntriesPlugin(),
|
|
4732
4768
|
farmPlugin({ ...config, isolatedClientBoundaryModules }, pluginManager),
|
|
4733
4769
|
_chunk22GUSVNJcjs.farmEnvironmentFunctionsPlugin.call(void 0, ),
|
|
@@ -4769,7 +4805,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4769
4805
|
resolve: {
|
|
4770
4806
|
alias: [
|
|
4771
4807
|
...shouldAliasReactServerToWebBuild(config.renderer, preset) ? [createFarmReactWebServerAlias(hasReactDomEdgeServerBuild(root))] : [],
|
|
4772
|
-
...Object.entries(
|
|
4808
|
+
...Object.entries(_chunkGIWC4CFJcjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
|
|
4773
4809
|
([find, replacement]) => ({ find, replacement })
|
|
4774
4810
|
)
|
|
4775
4811
|
],
|
|
@@ -4777,7 +4813,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4777
4813
|
dedupe: [...config.renderer.dedupe || []]
|
|
4778
4814
|
}
|
|
4779
4815
|
};
|
|
4780
|
-
await viteBuild(
|
|
4816
|
+
await viteBuild(_chunkGIWC4CFJcjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
|
|
4781
4817
|
} finally {
|
|
4782
4818
|
if (postcssConfigDir) {
|
|
4783
4819
|
try {
|
|
@@ -4858,44 +4894,6 @@ function generateNativeAuthIntegrationSource(auth) {
|
|
|
4858
4894
|
};
|
|
4859
4895
|
}
|
|
4860
4896
|
_chunkS3JO3N4Hcjs.__name.call(void 0, generateNativeAuthIntegrationSource, "generateNativeAuthIntegrationSource");
|
|
4861
|
-
function generateNativeMCPPluginSource(mcp) {
|
|
4862
|
-
if (_optionalChain([mcp, 'optionalAccess', _76 => _76.enabled]) !== true) {
|
|
4863
|
-
return { importSource: "", registerSource: "", pluginSource: "" };
|
|
4864
|
-
}
|
|
4865
|
-
return {
|
|
4866
|
-
importSource: `import { createFarmMCPPlugin as __farmCreateMCPPlugin } from "@farm.js/mcp/internal";`,
|
|
4867
|
-
registerSource: `function __farmMCPIsPlainObject(value) {
|
|
4868
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4869
|
-
const prototype = Object.getPrototypeOf(value);
|
|
4870
|
-
return prototype === Object.prototype || prototype === null;
|
|
4871
|
-
}
|
|
4872
|
-
|
|
4873
|
-
function __farmMergeMCPConfig(base, override) {
|
|
4874
|
-
const output = { ...base };
|
|
4875
|
-
for (const [key, value] of Object.entries(override)) {
|
|
4876
|
-
if (value === undefined) continue;
|
|
4877
|
-
output[key] =
|
|
4878
|
-
__farmMCPIsPlainObject(output[key]) && __farmMCPIsPlainObject(value)
|
|
4879
|
-
? __farmMergeMCPConfig(output[key], value)
|
|
4880
|
-
: value;
|
|
4881
|
-
}
|
|
4882
|
-
return output;
|
|
4883
|
-
}
|
|
4884
|
-
|
|
4885
|
-
const farmNativeMCPConfig = farmRuntimeConfigs.reduce((merged, runtimeConfig) => {
|
|
4886
|
-
const value = runtimeConfig?.mcp;
|
|
4887
|
-
if (value === undefined) return merged;
|
|
4888
|
-
if (value === false) return false;
|
|
4889
|
-
return __farmMergeMCPConfig(merged && merged !== false ? merged : {}, value);
|
|
4890
|
-
}, undefined);
|
|
4891
|
-
const farmNativeMCPPlugin =
|
|
4892
|
-
farmNativeMCPConfig && farmNativeMCPConfig.enabled !== false
|
|
4893
|
-
? __farmCreateMCPPlugin(farmNativeMCPConfig)
|
|
4894
|
-
: null;`,
|
|
4895
|
-
pluginSource: `...(farmNativeMCPPlugin ? [farmNativeMCPPlugin] : []),`
|
|
4896
|
-
};
|
|
4897
|
-
}
|
|
4898
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, generateNativeMCPPluginSource, "generateNativeMCPPluginSource");
|
|
4899
4897
|
function generateIntegrationRequestRuntimeSource(options) {
|
|
4900
4898
|
return `
|
|
4901
4899
|
function matchLocalIntegrationRequest(request) {
|
|
@@ -4946,6 +4944,24 @@ function getConfiguredSetCookieHeaders(headers) {
|
|
|
4946
4944
|
return value ? [value] : [];
|
|
4947
4945
|
}
|
|
4948
4946
|
|
|
4947
|
+
// Owned responses (core's owned-response.ts, RFC 0002) are edited in place.
|
|
4948
|
+
function farmEditableHeaders(response) {
|
|
4949
|
+
return (globalThis[Symbol.for("farm.ownedResponses")] ??= new WeakSet()).has(response)
|
|
4950
|
+
? response.headers
|
|
4951
|
+
: new Headers(response.headers);
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
function farmResponseWithHeaders(response, headers) {
|
|
4955
|
+
if (!headers || headers === response.headers) return response;
|
|
4956
|
+
const output = new Response(response.body, {
|
|
4957
|
+
status: response.status,
|
|
4958
|
+
statusText: response.statusText,
|
|
4959
|
+
headers,
|
|
4960
|
+
});
|
|
4961
|
+
(globalThis[Symbol.for("farm.ownedResponses")] ??= new WeakSet()).add(output);
|
|
4962
|
+
return output;
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4949
4965
|
function applyConfiguredResponseHeaders(response, pathname) {
|
|
4950
4966
|
if (preparedHeaderRoutes.length === 0) return response;
|
|
4951
4967
|
const pathnameSegments = splitRuntimePath(pathname).map(decodeRouteSegment);
|
|
@@ -4960,12 +4976,12 @@ function applyConfiguredResponseHeaders(response, pathname) {
|
|
|
4960
4976
|
const normalizedKey = header.key.toLowerCase();
|
|
4961
4977
|
if (normalizedKey === "set-cookie") {
|
|
4962
4978
|
if (getConfiguredSetCookieHeaders(currentHeaders).includes(header.value)) continue;
|
|
4963
|
-
if (!headers) headers =
|
|
4979
|
+
if (!headers) headers = farmEditableHeaders(response);
|
|
4964
4980
|
headers.append("Set-Cookie", header.value);
|
|
4965
4981
|
} else {
|
|
4966
4982
|
const currentValue = currentHeaders.get(header.key);
|
|
4967
4983
|
if (currentValue === header.value) continue;
|
|
4968
|
-
if (!headers) headers =
|
|
4984
|
+
if (!headers) headers = farmEditableHeaders(response);
|
|
4969
4985
|
if (normalizedKey === "link") {
|
|
4970
4986
|
appendFarmLinkHeader(headers, header.value);
|
|
4971
4987
|
} else {
|
|
@@ -4975,12 +4991,7 @@ function applyConfiguredResponseHeaders(response, pathname) {
|
|
|
4975
4991
|
}
|
|
4976
4992
|
}
|
|
4977
4993
|
|
|
4978
|
-
|
|
4979
|
-
return new Response(response.body, {
|
|
4980
|
-
status: response.status,
|
|
4981
|
-
statusText: response.statusText,
|
|
4982
|
-
headers,
|
|
4983
|
-
});
|
|
4994
|
+
return farmResponseWithHeaders(response, headers);
|
|
4984
4995
|
}
|
|
4985
4996
|
`.trim();
|
|
4986
4997
|
}
|
|
@@ -5007,7 +5018,73 @@ function generatePreloadResponseRuntimeSource() {
|
|
|
5007
5018
|
// reading it, so a changed body is never paired with a stale string.
|
|
5008
5019
|
const farmBufferedHtml = new WeakMap();
|
|
5009
5020
|
|
|
5021
|
+
// A Response Farm creates for this request. Later header steps edit it in place
|
|
5022
|
+
// instead of copying it; responses from app code are never owned. Same registry
|
|
5023
|
+
// as core's owned-response.ts (RFC 0002).
|
|
5024
|
+
function farmOwnedResponse(body, init) {
|
|
5025
|
+
const response = new Response(body, init);
|
|
5026
|
+
(globalThis[Symbol.for("farm.ownedResponses")] ??= new WeakSet()).add(response);
|
|
5027
|
+
return response;
|
|
5028
|
+
}
|
|
5029
|
+
|
|
5030
|
+
// node-server registers srvx's FastResponse here (RFC 0002). A buffered page
|
|
5031
|
+
// built with it keeps its HTML as a string until something reads the body, and
|
|
5032
|
+
// srvx writes that string in one call; other runtimes keep the Web Response.
|
|
5033
|
+
let FarmNodePageResponse;
|
|
5034
|
+
function useFarmNodePageResponse(ResponseClass) {
|
|
5035
|
+
FarmNodePageResponse = ResponseClass;
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
// HTML of buffered pages built as FarmNodePageResponse, keyed by the response:
|
|
5039
|
+
// its body always comes from this string, and looking it up never creates the
|
|
5040
|
+
// Web body the way reading response.body would.
|
|
5041
|
+
const farmLazyBufferedHtml = new WeakMap();
|
|
5042
|
+
|
|
5043
|
+
function hasFarmContentType(headers) {
|
|
5044
|
+
if (!headers) return false;
|
|
5045
|
+
if (typeof headers.has === "function") return headers.has("content-type");
|
|
5046
|
+
for (const key in headers) if (key.toLowerCase() === "content-type") return true;
|
|
5047
|
+
return false;
|
|
5048
|
+
}
|
|
5049
|
+
|
|
5050
|
+
// A complete HTML document Farm built for this request. Same contract as
|
|
5051
|
+
// farmOwnedResponse followed by rememberFarmBufferedHtml.
|
|
5052
|
+
function farmOwnedHtmlResponse(html, init) {
|
|
5053
|
+
if (
|
|
5054
|
+
!FarmNodePageResponse ||
|
|
5055
|
+
typeof html !== "string" ||
|
|
5056
|
+
html.charCodeAt(0) === 0xfeff ||
|
|
5057
|
+
!hasFarmContentType(init?.headers)
|
|
5058
|
+
) {
|
|
5059
|
+
return rememberFarmBufferedHtml(farmOwnedResponse(html, init), html);
|
|
5060
|
+
}
|
|
5061
|
+
const response = new FarmNodePageResponse(html, init);
|
|
5062
|
+
(globalThis[Symbol.for("farm.ownedResponses")] ??= new WeakSet()).add(response);
|
|
5063
|
+
farmLazyBufferedHtml.set(response, html);
|
|
5064
|
+
return response;
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
function isFarmOwnedResponseForPreload(response) {
|
|
5068
|
+
return (globalThis[Symbol.for("farm.ownedResponses")] ??= new WeakSet()).has(response);
|
|
5069
|
+
}
|
|
5070
|
+
|
|
5071
|
+
// Header-only rebuild: in place for an owned response, otherwise a copy Farm owns.
|
|
5072
|
+
function farmPreloadHeadersResponse(response, edit) {
|
|
5073
|
+
if (isFarmOwnedResponseForPreload(response)) {
|
|
5074
|
+
edit(response.headers);
|
|
5075
|
+
return response;
|
|
5076
|
+
}
|
|
5077
|
+
const headers = new Headers(response.headers);
|
|
5078
|
+
edit(headers);
|
|
5079
|
+
return farmOwnedResponse(response.body, {
|
|
5080
|
+
status: response.status,
|
|
5081
|
+
statusText: response.statusText,
|
|
5082
|
+
headers,
|
|
5083
|
+
});
|
|
5084
|
+
}
|
|
5085
|
+
|
|
5010
5086
|
function rememberFarmBufferedHtml(response, html) {
|
|
5087
|
+
if (farmLazyBufferedHtml.has(response)) return response;
|
|
5011
5088
|
// Response.text() strips a leading BOM, so a BOM document keeps reading its
|
|
5012
5089
|
// body to preserve that behavior.
|
|
5013
5090
|
if (typeof html === "string" && html.charCodeAt(0) !== 0xfeff && response.body) {
|
|
@@ -5017,6 +5094,8 @@ function rememberFarmBufferedHtml(response, html) {
|
|
|
5017
5094
|
}
|
|
5018
5095
|
|
|
5019
5096
|
function getFarmOwnedBufferedHtml(response) {
|
|
5097
|
+
const lazyHtml = farmLazyBufferedHtml.get(response);
|
|
5098
|
+
if (lazyHtml !== undefined) return lazyHtml;
|
|
5020
5099
|
const body = response.body;
|
|
5021
5100
|
if (!body || response.bodyUsed || body.locked) return undefined;
|
|
5022
5101
|
return farmBufferedHtml.get(body);
|
|
@@ -5039,17 +5118,14 @@ async function applyFarmPreloadBudget(response, pathname, request) {
|
|
|
5039
5118
|
const isBuffered = bufferedMarker === "1" || hasNoHtmlPreloads;
|
|
5040
5119
|
if (!isHtml) {
|
|
5041
5120
|
if (!isStreaming && !isBuffered) return response;
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
return new Response(response.body, {
|
|
5046
|
-
status: response.status,
|
|
5047
|
-
statusText: response.statusText,
|
|
5048
|
-
headers,
|
|
5121
|
+
return farmPreloadHeadersResponse(response, (editable) => {
|
|
5122
|
+
editable.delete("x-farm-preload-streaming");
|
|
5123
|
+
editable.delete("x-farm-preload-buffered");
|
|
5049
5124
|
});
|
|
5050
5125
|
}
|
|
5051
5126
|
|
|
5052
|
-
|
|
5127
|
+
const isLazyPage = farmLazyBufferedHtml.has(response);
|
|
5128
|
+
if (isStreaming || !isBuffered || (!isLazyPage && response.body === null)) {
|
|
5053
5129
|
const managed = manageFarmLinkHeaderPreloads(linkHeader, farmPreloadConfig);
|
|
5054
5130
|
reportFarmPreloadWarnings(managed.warnings, managed.warnings.length > 0
|
|
5055
5131
|
? "route " + (pathname ?? getFarmRoutePathname(new URL(request.url).pathname))
|
|
@@ -5059,42 +5135,43 @@ async function applyFarmPreloadBudget(response, pathname, request) {
|
|
|
5059
5135
|
if (!headers.has("x-farm-preload-streaming") &&
|
|
5060
5136
|
!headers.has("x-farm-preload-buffered") &&
|
|
5061
5137
|
(managed.value || null) === headers.get("Link")) return response;
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
return new Response(response.body, {
|
|
5068
|
-
status: response.status,
|
|
5069
|
-
statusText: response.statusText,
|
|
5070
|
-
headers,
|
|
5138
|
+
return farmPreloadHeadersResponse(response, (editable) => {
|
|
5139
|
+
editable.delete("x-farm-preload-streaming");
|
|
5140
|
+
editable.delete("x-farm-preload-buffered");
|
|
5141
|
+
if (managed.value) editable.set("Link", managed.value);
|
|
5142
|
+
else editable.delete("Link");
|
|
5071
5143
|
});
|
|
5072
5144
|
}
|
|
5073
5145
|
|
|
5074
5146
|
// Keep the document/header budget semantics (including unchanged Link
|
|
5075
5147
|
// formatting), but do not consume and re-encode a proven preload-free body.
|
|
5076
|
-
headers = new Headers(headers);
|
|
5077
|
-
headers.delete("x-farm-preload-streaming");
|
|
5078
|
-
headers.delete("x-farm-preload-buffered");
|
|
5079
5148
|
const ownedHtml = hasNoHtmlPreloads ? undefined : getFarmOwnedBufferedHtml(response);
|
|
5080
5149
|
const html = hasNoHtmlPreloads ? "" : (ownedHtml ?? await response.text());
|
|
5081
5150
|
const managed = manageFarmDocumentPreloads(html, linkHeader, farmPreloadConfig);
|
|
5082
5151
|
// A remembered document the budget left unchanged keeps its unread body.
|
|
5083
5152
|
const reusesBody = hasNoHtmlPreloads || (ownedHtml !== undefined && managed.html === html);
|
|
5084
|
-
if (ownedHtml !== undefined && !reusesBody
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
if (managed.html !== html) headers.delete("Content-Length");
|
|
5153
|
+
if (ownedHtml !== undefined && !reusesBody && !isLazyPage) {
|
|
5154
|
+
response.body?.cancel().catch(() => {});
|
|
5155
|
+
}
|
|
5088
5156
|
reportFarmPreloadWarnings(managed.warnings, managed.warnings.length > 0
|
|
5089
5157
|
? "route " + (pathname ?? getFarmRoutePathname(new URL(request.url).pathname))
|
|
5090
5158
|
: undefined);
|
|
5091
|
-
const
|
|
5159
|
+
const applyBudgetHeaders = (editable) => {
|
|
5160
|
+
editable.delete("x-farm-preload-streaming");
|
|
5161
|
+
editable.delete("x-farm-preload-buffered");
|
|
5162
|
+
if (managed.linkHeader) editable.set("Link", managed.linkHeader);
|
|
5163
|
+
else editable.delete("Link");
|
|
5164
|
+
if (managed.html !== html) editable.delete("Content-Length");
|
|
5165
|
+
};
|
|
5166
|
+
if (reusesBody) return farmPreloadHeadersResponse(response, applyBudgetHeaders);
|
|
5167
|
+
const rebuiltHeaders = new Headers(headers);
|
|
5168
|
+
applyBudgetHeaders(rebuiltHeaders);
|
|
5169
|
+
// A rebuilt document is still a complete string Farm holds.
|
|
5170
|
+
return farmOwnedHtmlResponse(managed.html, {
|
|
5092
5171
|
status: response.status,
|
|
5093
5172
|
statusText: response.statusText,
|
|
5094
|
-
headers,
|
|
5173
|
+
headers: rebuiltHeaders,
|
|
5095
5174
|
});
|
|
5096
|
-
// A rebuilt document is still a complete string Farm holds.
|
|
5097
|
-
return reusesBody ? output : rememberFarmBufferedHtml(output, managed.html);
|
|
5098
5175
|
}
|
|
5099
5176
|
`.trim();
|
|
5100
5177
|
}
|
|
@@ -5112,14 +5189,14 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
|
|
|
5112
5189
|
_chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmRendererAppSetupServerCode, "generateFarmRendererAppSetupServerCode");
|
|
5113
5190
|
function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache) {
|
|
5114
5191
|
const hasCompressionRuntime = config.compress && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
|
|
5115
|
-
const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access',
|
|
5192
|
+
const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _76 => _76.agent, 'optionalAccess', _77 => _77.crawlers, 'optionalAccess', _78 => _78.enabled])) && !applicationMetadataRoutes.some(
|
|
5116
5193
|
(metadata) => metadata.kind === "robots" && metadata.pattern === "/"
|
|
5117
5194
|
);
|
|
5118
5195
|
const hasPluginRuntime = hasRuntimeIntegrationConfig || hasServerRuntimePlugins;
|
|
5119
5196
|
const hasInfraAnalyticsRuntime = config.analytics !== false && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
|
|
5120
5197
|
const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
|
|
5121
5198
|
const adapterOwnsDocsRuntime = Boolean(
|
|
5122
|
-
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access',
|
|
5199
|
+
_chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _79 => _79.docs, 'optionalAccess', _80 => _80.enabled]) && _optionalChain([config, 'access', _81 => _81.docs, 'access', _82 => _82.adapter, 'optionalAccess', _83 => _83.server]) && config.docs.adapter.react
|
|
5123
5200
|
);
|
|
5124
5201
|
const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
|
|
5125
5202
|
const hasIsolatedClientGraphRuntime = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && isolatedClientBoundaryModules.size > 0;
|
|
@@ -5127,6 +5204,7 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
|
|
|
5127
5204
|
config.renderer,
|
|
5128
5205
|
_chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset)
|
|
5129
5206
|
);
|
|
5207
|
+
const hasReactSyncRender = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer);
|
|
5130
5208
|
const rendererServerImports = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) ? `import * as React from "react";
|
|
5131
5209
|
import * as ReactDOMServer from "react-dom/server";${hasIsolatedClientGraphRuntime ? '\nimport { isolateFarmServerPageGraph, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";' : ""}` : `import React, * as ReactDOMServer from ${JSON.stringify(config.renderer.server)};${generateFarmRendererAppSetupServerCode(config)}`;
|
|
5132
5210
|
const routeClientGraphServerRuntime = hasIsolatedClientGraphRuntime ? `function wrapFarmRouteClientGraph(element) {
|
|
@@ -5144,7 +5222,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5144
5222
|
(image) => image.sourceType === "module"
|
|
5145
5223
|
);
|
|
5146
5224
|
const hasMiddlewareRuntime = middlewareRoutes.length > 0 || hasFarmMiddlewareConfig(config.middleware);
|
|
5147
|
-
const farmDocsFontAssets = _optionalChain([config, 'access',
|
|
5225
|
+
const farmDocsFontAssets = _optionalChain([config, 'access', _84 => _84.docs, 'optionalAccess', _85 => _85.enabled]) ? _chunkHREOKQWTcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
|
|
5148
5226
|
const integrationProviders = _chunkZ5HIWVDPcjs.getIntegrationProviders.call(void 0, config.integrations);
|
|
5149
5227
|
const renderedIntegrationProviders = integrationProviders.filter(
|
|
5150
5228
|
(provider) => provider.component || provider.type === "clerk"
|
|
@@ -5154,16 +5232,16 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5154
5232
|
`Integration provider components are not supported by the "${config.renderer.name}" renderer.`
|
|
5155
5233
|
);
|
|
5156
5234
|
}
|
|
5157
|
-
const providerServerModules =
|
|
5235
|
+
const providerServerModules = _chunkGIWC4CFJcjs.generateFarmIntegrationProviderServerModules.call(void 0,
|
|
5158
5236
|
renderedIntegrationProviders,
|
|
5159
5237
|
config.root,
|
|
5160
5238
|
_nullishCoalesce(config.renderer.componentExtensions, () => ( []))
|
|
5161
5239
|
);
|
|
5162
5240
|
const resolvedIntegrationProviderFallback = Object.fromEntries(
|
|
5163
5241
|
Object.entries(config.integrations).flatMap(([name, integration]) => {
|
|
5164
|
-
const configuredProviders = _optionalChain([integration, 'optionalAccess',
|
|
5242
|
+
const configuredProviders = _optionalChain([integration, 'optionalAccess', _86 => _86.providers]);
|
|
5165
5243
|
const providers = Array.isArray(configuredProviders) ? configuredProviders : [];
|
|
5166
|
-
if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess',
|
|
5244
|
+
if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _87 => _87.component]) === "function")) {
|
|
5167
5245
|
throw new Error(
|
|
5168
5246
|
`Integration provider components in production must use an importable component reference, for example component: { module: "@/components/provider" }.`
|
|
5169
5247
|
);
|
|
@@ -5174,14 +5252,14 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5174
5252
|
const unsupportedIntegrationProvider = renderedIntegrationProviders.find(
|
|
5175
5253
|
(provider) => provider.supportsIsolatedHydration !== true
|
|
5176
5254
|
);
|
|
5177
|
-
const isolatedHydrationMode =
|
|
5178
|
-
_optionalChain([config, 'access',
|
|
5255
|
+
const isolatedHydrationMode = _chunkGIWC4CFJcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
|
|
5256
|
+
_optionalChain([config, 'access', _88 => _88.experimental, 'optionalAccess', _89 => _89.isolatedClientHydration]),
|
|
5179
5257
|
{
|
|
5180
|
-
serverComponents: _optionalChain([config, 'access',
|
|
5258
|
+
serverComponents: _optionalChain([config, 'access', _90 => _90.experimental, 'optionalAccess', _91 => _91.serverComponents]) === true,
|
|
5181
5259
|
hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
|
|
5182
5260
|
}
|
|
5183
5261
|
);
|
|
5184
|
-
const hydrationPlanOptions =
|
|
5262
|
+
const hydrationPlanOptions = _chunkGIWC4CFJcjs.getFarmClientHydrationPlanOptions.call(void 0,
|
|
5185
5263
|
config.renderer,
|
|
5186
5264
|
Boolean(unsupportedIntegrationProvider)
|
|
5187
5265
|
);
|
|
@@ -5196,7 +5274,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5196
5274
|
hydrationPlanOptions
|
|
5197
5275
|
)
|
|
5198
5276
|
}));
|
|
5199
|
-
const markdownPagePlan =
|
|
5277
|
+
const markdownPagePlan = _chunkGIWC4CFJcjs.createMarkdownPageHydrationPlanner.call(void 0,
|
|
5200
5278
|
_chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), config.root),
|
|
5201
5279
|
config.root,
|
|
5202
5280
|
isolatedHydrationMode,
|
|
@@ -5205,7 +5283,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5205
5283
|
const pageHydrationPlans = new Map(
|
|
5206
5284
|
pageRoutes.map((route) => [
|
|
5207
5285
|
route.modulePath,
|
|
5208
|
-
|
|
5286
|
+
_chunkNXG66MR7cjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
5209
5287
|
route.modulePath,
|
|
5210
5288
|
config.root,
|
|
5211
5289
|
isolatedHydrationMode,
|
|
@@ -5214,7 +5292,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5214
5292
|
)
|
|
5215
5293
|
])
|
|
5216
5294
|
);
|
|
5217
|
-
|
|
5295
|
+
_chunkGIWC4CFJcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
|
|
5218
5296
|
layoutHydrationPlans.map((layout) => ({
|
|
5219
5297
|
pattern: layout.pattern,
|
|
5220
5298
|
depth: layout.pattern.split("/").filter(Boolean).length,
|
|
@@ -5242,7 +5320,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5242
5320
|
apiRegistrations.push(`
|
|
5243
5321
|
{
|
|
5244
5322
|
path: ${JSON.stringify(route.path)},
|
|
5245
|
-
methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access',
|
|
5323
|
+
methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _92 => _92.pluginMethods, 'optionalAccess', _93 => _93.includes, 'call', _94 => _94(method)])))},
|
|
5246
5324
|
endpoints: ${varName},
|
|
5247
5325
|
}`);
|
|
5248
5326
|
});
|
|
@@ -5255,7 +5333,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5255
5333
|
}).map(({ route }) => route);
|
|
5256
5334
|
orderedPageRoutes.forEach((route, index) => {
|
|
5257
5335
|
const varName = `pageRoute${index}`;
|
|
5258
|
-
if (
|
|
5336
|
+
if (_chunkNXG66MR7cjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
|
|
5259
5337
|
pageRegistrations.push(`
|
|
5260
5338
|
{
|
|
5261
5339
|
pattern: ${JSON.stringify(route.pattern)},
|
|
@@ -5475,25 +5553,25 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5475
5553
|
const infraAnalyticsImport = hasInfraAnalyticsRuntime ? `import { ${hasPluginRuntime ? "createFarmInfraAnalyticsPlugin" : "createFarmInfraAnalyticsRecorder"} } from "@farm.js/core/internal/infra-analytics-runtime";` : "";
|
|
5476
5554
|
const compressionRuntimeImport = hasCompressionRuntime ? `import { compressFarmResponse${hasPluginRuntime ? ", createCompressionPlugin" : ""} } from "@farm.js/core/internal/compression-runtime";` : "";
|
|
5477
5555
|
const i18nServerImport = config.i18n.enabled ? `import { _runWithFarmI18nRequest, _setDefaultFarmI18nRuntime, createFarmI18nRuntime, getFarmI18nClientSnapshot } from "@farm.js/core/i18n/server";` : "";
|
|
5478
|
-
const docsHandlerImport = _optionalChain([config, 'access',
|
|
5556
|
+
const docsHandlerImport = _optionalChain([config, 'access', _95 => _95.docs, 'optionalAccess', _96 => _96.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
|
|
5479
5557
|
const isFarmDocsAPIRequest = (requestOrPathname) => {
|
|
5480
5558
|
const pathname = typeof requestOrPathname === "string"
|
|
5481
5559
|
? requestOrPathname
|
|
5482
5560
|
: new URL(requestOrPathname.url).pathname;
|
|
5483
|
-
const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess',
|
|
5561
|
+
const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _97 => _97.apiPath]) || "/api/docs")};
|
|
5484
5562
|
return pathname === apiPath || pathname.startsWith(apiPath + "/");
|
|
5485
5563
|
};` : adapterOwnsDocsRuntime ? `import { isFarmDocsAPIRequest } from "@farm.js/core/docs";
|
|
5486
5564
|
import { createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler } from ${JSON.stringify(config.docs.adapter.server)};
|
|
5487
5565
|
import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
|
|
5488
5566
|
import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
|
|
5489
|
-
const docsFontImport = _optionalChain([config, 'access',
|
|
5490
|
-
const docsRuntimeImport = _optionalChain([config, 'access',
|
|
5567
|
+
const docsFontImport = _optionalChain([config, 'access', _98 => _98.docs, 'optionalAccess', _99 => _99.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
|
|
5568
|
+
const docsRuntimeImport = _optionalChain([config, 'access', _100 => _100.docs, 'optionalAccess', _101 => _101.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
|
|
5491
5569
|
import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
|
|
5492
5570
|
import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
5493
|
-
const markdownHandlerImport = _optionalChain([config, 'access',
|
|
5571
|
+
const markdownHandlerImport = _optionalChain([config, 'access', _102 => _102.md, 'optionalAccess', _103 => _103.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
5494
5572
|
const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;";
|
|
5495
5573
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5496
|
-
const mdxComponentsPath = typeof _optionalChain([config, 'access',
|
|
5574
|
+
const mdxComponentsPath = typeof _optionalChain([config, 'access', _104 => _104.mdx, 'optionalAccess', _105 => _105.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
|
|
5497
5575
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
5498
5576
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
5499
5577
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -5511,7 +5589,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
5511
5589
|
const integrationRuntimeImport = integrationRuntimeExports.length ? `import { ${integrationRuntimeExports.join(", ")} } from "@farm.js/core/integrations";` : "";
|
|
5512
5590
|
const instrumentationImport = instrumentationPath ? `import * as FarmInstrumentationModule from ${toVirtualEntryImportSpecifier(instrumentationPath)};` : "";
|
|
5513
5591
|
const nativeAuth = generateNativeAuthIntegrationSource(config.auth);
|
|
5514
|
-
const nativeMCP = generateNativeMCPPluginSource(config.mcp);
|
|
5592
|
+
const nativeMCP = _chunkXD32KALFcjs.generateNativeMCPPluginSource.call(void 0, config.mcp);
|
|
5515
5593
|
const integrationImports = `
|
|
5516
5594
|
${configModulePath ? `import * as FarmUserConfigModule from ${toVirtualEntryImportSpecifier(configModulePath)};` : ""}
|
|
5517
5595
|
${layerConfigImports}
|
|
@@ -5652,6 +5730,7 @@ ${routeClientGraphServerRuntime}
|
|
|
5652
5730
|
|
|
5653
5731
|
const farmRendererStreamingCapabilities = ${JSON.stringify(rendererStreamingCapabilities)};
|
|
5654
5732
|
const farmRendererName = ${JSON.stringify(config.renderer.name)};
|
|
5733
|
+
const farmReactSyncRender = ${JSON.stringify(hasReactSyncRender)};
|
|
5655
5734
|
const farmRendererRuntime = ${JSON.stringify(_chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset))};
|
|
5656
5735
|
const farmRendererRuntimeStreamingCapabilities = ReactDOMServer.capabilities &&
|
|
5657
5736
|
ReactDOMServer.capabilities.streaming;
|
|
@@ -5697,7 +5776,7 @@ const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
|
|
|
5697
5776
|
|
|
5698
5777
|
function FarmDefault404Page() {
|
|
5699
5778
|
return React.createElement(React.Fragment, null,
|
|
5700
|
-
React.createElement("style", null, ${JSON.stringify(
|
|
5779
|
+
React.createElement("style", null, ${JSON.stringify(_chunkGIWC4CFJcjs.DEFAULT_NOT_FOUND_STYLES)}),
|
|
5701
5780
|
React.createElement("main", {
|
|
5702
5781
|
className: "farm-default-not-found",
|
|
5703
5782
|
"aria-labelledby": "farm-default-not-found-title",
|
|
@@ -5825,14 +5904,14 @@ const farmImageHandler = ${imageRuntime === "none" ? "null" : imageRuntime === "
|
|
|
5825
5904
|
onError(error) { console.error("[Farm Image]", error); },
|
|
5826
5905
|
})`};
|
|
5827
5906
|
const farmMarkdownConfig = ${JSON.stringify(config.md)};
|
|
5828
|
-
const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access',
|
|
5829
|
-
${_optionalChain([config, 'access',
|
|
5907
|
+
const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _106 => _106.agent, 'optionalAccess', _107 => _107.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
|
|
5908
|
+
${_optionalChain([config, 'access', _108 => _108.agent, 'optionalAccess', _109 => _109.llmsTxt, 'optionalAccess', _110 => _110.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
|
|
5830
5909
|
const farmMdxConfig = ${JSON.stringify({
|
|
5831
5910
|
...config.mdx,
|
|
5832
|
-
components: typeof _optionalChain([config, 'access',
|
|
5911
|
+
components: typeof _optionalChain([config, 'access', _111 => _111.mdx, 'optionalAccess', _112 => _112.components]) === "string" ? config.mdx.components : void 0
|
|
5833
5912
|
})};
|
|
5834
5913
|
const configuredFarmMdxComponents = farmUserConfig?.mdx?.components;
|
|
5835
|
-
${_optionalChain([config, 'access',
|
|
5914
|
+
${_optionalChain([config, 'access', _113 => _113.agent, 'optionalAccess', _114 => _114.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
|
|
5836
5915
|
// environment this was built in, since Netlify exposes its deploy context only
|
|
5837
5916
|
// to the build.
|
|
5838
5917
|
const farmNoindexPreview = resolveFarmPreviewDeployment(
|
|
@@ -5880,7 +5959,7 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
|
|
|
5880
5959
|
});
|
|
5881
5960
|
const farmI18nRuntime = ${config.i18n.enabled ? `createFarmI18nRuntime(farmI18nConfig, ${JSON.stringify(i18nCatalogs)})` : "null"};
|
|
5882
5961
|
${config.i18n.enabled ? "_setDefaultFarmI18nRuntime(farmI18nRuntime);" : ""}
|
|
5883
|
-
const farmDocsBundledContentDir = ${_optionalChain([config, 'access',
|
|
5962
|
+
const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _115 => _115.docs, 'optionalAccess', _116 => _116.enabled]) && !hasPrecompiledDocs ? `(() => {
|
|
5884
5963
|
try {
|
|
5885
5964
|
const currentDir = farmDocsDirname(farmDocsFileURLToPath(import.meta.url));
|
|
5886
5965
|
const candidates = [
|
|
@@ -5901,7 +5980,7 @@ globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
|
|
|
5901
5980
|
docs: farmDocsResolvedConfig,
|
|
5902
5981
|
};
|
|
5903
5982
|
const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
|
|
5904
|
-
const farmDocsHandler = ${_optionalChain([config, 'access',
|
|
5983
|
+
const farmDocsHandler = ${_optionalChain([config, 'access', _117 => _117.docs, 'optionalAccess', _118 => _118.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
|
|
5905
5984
|
${docsConfigModulePath ? "...(farmDocsConfigModule.default || farmDocsConfigModule),\n ...farmDocsResolvedConfig.configOverrides," : "...farmDocsResolvedConfig.config,"}
|
|
5906
5985
|
entry: farmDocsResolvedConfig.config?.entry || String(farmDocsResolvedConfig.entry || "/docs").replace(/^\\/+|\\/+$/g, "") || "docs",
|
|
5907
5986
|
docsPath: farmDocsResolvedConfig.entry,
|
|
@@ -5929,14 +6008,14 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _118 => _118.docs, '
|
|
|
5929
6008
|
fontStylesheetHref: "/farm-fonts.css",
|
|
5930
6009
|
globalStylesheetHref: "/assets/globals.css",
|
|
5931
6010
|
})` : "null"};
|
|
5932
|
-
const farmDocsAPIHandler = ${_optionalChain([config, 'access',
|
|
6011
|
+
const farmDocsAPIHandler = ${_optionalChain([config, 'access', _119 => _119.docs, 'optionalAccess', _120 => _120.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig })` : "null"};
|
|
5933
6012
|
|
|
5934
6013
|
// API routes bundled at build time
|
|
5935
6014
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
5936
6015
|
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path7, methods }) => ({ path: path7, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)} })` : ""};
|
|
5937
6016
|
const farmLocalAPIBasePath = ${JSON.stringify(_chunkWPYFSQKKcjs.resolveFarmAPIServerBasePath.call(void 0, config.api))};
|
|
5938
6017
|
const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
|
|
5939
|
-
${_optionalChain([config, 'access',
|
|
6018
|
+
${_optionalChain([config, 'access', _121 => _121.agent, 'optionalAccess', _122 => _122.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunkNPPL5YDTcjs.resolveFarmApiCatalogInput.call(void 0, config))};
|
|
5940
6019
|
` : ""}
|
|
5941
6020
|
function isFarmLocalAPIPathname(pathname) {
|
|
5942
6021
|
return farmLocalAPIBasePath !== "/" &&
|
|
@@ -6051,8 +6130,10 @@ function escapeFarmHtmlAttribute(value) {
|
|
|
6051
6130
|
.replace(/>/g, ">");
|
|
6052
6131
|
}
|
|
6053
6132
|
|
|
6054
|
-
async function renderFarmElement(ReactDOMServer, element) {
|
|
6133
|
+
async function renderFarmElement(ReactDOMServer, element, routeKey) {
|
|
6055
6134
|
const streamErrors = [];
|
|
6135
|
+
const syncHtml = renderFarmElementSync(ReactDOMServer, element, routeKey);
|
|
6136
|
+
if (syncHtml !== undefined) return { html: syncHtml, shellHtml: syncHtml, streamErrors };
|
|
6056
6137
|
let encoder;
|
|
6057
6138
|
const normalizeChunk = function(chunk) {
|
|
6058
6139
|
if (typeof chunk === "string") return (encoder ||= new TextEncoder()).encode(chunk);
|
|
@@ -6123,6 +6204,7 @@ async function renderFarmElement(ReactDOMServer, element) {
|
|
|
6123
6204
|
}
|
|
6124
6205
|
throwStreamError();
|
|
6125
6206
|
const html = decodeChunks(chunks);
|
|
6207
|
+
rememberFarmSyncRender(routeKey, html);
|
|
6126
6208
|
return { html, shellHtml: html, streamErrors };
|
|
6127
6209
|
}
|
|
6128
6210
|
|
|
@@ -6254,6 +6336,7 @@ async function renderFarmElement(ReactDOMServer, element) {
|
|
|
6254
6336
|
await complete;
|
|
6255
6337
|
throwStreamError();
|
|
6256
6338
|
const html = decodeChunks(chunks);
|
|
6339
|
+
rememberFarmSyncRender(routeKey, html);
|
|
6257
6340
|
return { html, shellHtml: html, streamErrors };
|
|
6258
6341
|
}
|
|
6259
6342
|
|
|
@@ -6294,6 +6377,45 @@ async function renderFarmElementToString(ReactDOMServer, element) {
|
|
|
6294
6377
|
return html;
|
|
6295
6378
|
}
|
|
6296
6379
|
|
|
6380
|
+
// Most pages render without suspending. React's renderToString renders them in
|
|
6381
|
+
// one synchronous pass with string output, about half the CPU of the streaming
|
|
6382
|
+
// renderer, and the same markup, except that React 19's streaming renderer adds
|
|
6383
|
+
// a doctype before an <html> root. A route uses it only after a streaming render
|
|
6384
|
+
// of that route finished without suspending (remembering whether that render
|
|
6385
|
+
// started with a doctype), so a page that suspends keeps streaming and renders
|
|
6386
|
+
// once. If such a route suspends later (a Suspense boundary left to the
|
|
6387
|
+
// client, marked <!--$!-->, or a throw), that request renders again through the
|
|
6388
|
+
// streaming path and the route streams for the rest of this server process.
|
|
6389
|
+
const farmSyncRenderRoutes = new Map();
|
|
6390
|
+
const farmStreamingRenderRoutes = new Set();
|
|
6391
|
+
const FARM_STREAMED_DOCTYPE = "<!DOCTYPE html>";
|
|
6392
|
+
|
|
6393
|
+
function rememberFarmSyncRender(routeKey, streamedHtml) {
|
|
6394
|
+
if (!farmReactSyncRender || routeKey === undefined) return;
|
|
6395
|
+
if (!farmStreamingRenderRoutes.has(routeKey)) {
|
|
6396
|
+
farmSyncRenderRoutes.set(routeKey, streamedHtml.startsWith(FARM_STREAMED_DOCTYPE));
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6399
|
+
|
|
6400
|
+
function renderFarmElementSync(ReactDOMServer, element, routeKey) {
|
|
6401
|
+
if (!farmReactSyncRender) return undefined;
|
|
6402
|
+
const addsDoctype = routeKey === undefined ? undefined : farmSyncRenderRoutes.get(routeKey);
|
|
6403
|
+
if (addsDoctype === undefined) return undefined;
|
|
6404
|
+
if (typeof ReactDOMServer.renderToString !== "function") return undefined;
|
|
6405
|
+
let html;
|
|
6406
|
+
try {
|
|
6407
|
+
html = ReactDOMServer.renderToString(element);
|
|
6408
|
+
} catch {
|
|
6409
|
+
html = undefined;
|
|
6410
|
+
}
|
|
6411
|
+
if (typeof html !== "string" || html.includes("<!--$!-->")) {
|
|
6412
|
+
farmSyncRenderRoutes.delete(routeKey);
|
|
6413
|
+
farmStreamingRenderRoutes.add(routeKey);
|
|
6414
|
+
return undefined;
|
|
6415
|
+
}
|
|
6416
|
+
return addsDoctype && html.startsWith("<html") ? FARM_STREAMED_DOCTYPE + html : html;
|
|
6417
|
+
}
|
|
6418
|
+
|
|
6297
6419
|
function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
|
|
6298
6420
|
const encoder = new TextEncoder();
|
|
6299
6421
|
const reader = contentStream.getReader();
|
|
@@ -6333,7 +6455,7 @@ function peelFarmDocumentPrefix(markup) {
|
|
|
6333
6455
|
let inner = markup.replace(/^\\s+/, "");
|
|
6334
6456
|
let hoisted = "";
|
|
6335
6457
|
const wrapper = /^<div\\b[^>]*style=["']display\\s*:\\s*contents["'][^>]*>/i;
|
|
6336
|
-
const hoistable = /${
|
|
6458
|
+
const hoistable = /${_chunkGIWC4CFJcjs.HOISTED_HEAD_ELEMENT.source}/i;
|
|
6337
6459
|
let match;
|
|
6338
6460
|
while ((match = wrapper.exec(inner) || hoistable.exec(inner))) {
|
|
6339
6461
|
if (!/^<div/i.test(match[0])) hoisted += match[0];
|
|
@@ -7042,7 +7164,7 @@ function hasLocalRequestRoute(request, routePathname) {
|
|
|
7042
7164
|
if (${imageRuntime === "none" ? "false" : `pathname === ${JSON.stringify(config.images.path)}`}) {
|
|
7043
7165
|
return true;
|
|
7044
7166
|
}
|
|
7045
|
-
${_optionalChain([config, 'access',
|
|
7167
|
+
${_optionalChain([config, 'access', _123 => _123.docs, 'optionalAccess', _124 => _124.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
|
|
7046
7168
|
if (
|
|
7047
7169
|
isFarmDocsAPIRequest(pathname) ||
|
|
7048
7170
|
docsPath === "/" ||
|
|
@@ -7068,7 +7190,7 @@ function getFarmPluginRequestOptions(request) {
|
|
|
7068
7190
|
route: { ...route, pattern: normalizeRuntimePath(farmOpenAPIReference.route) },
|
|
7069
7191
|
};
|
|
7070
7192
|
}
|
|
7071
|
-
const isDocsAPIRequest = ${_optionalChain([config, 'access',
|
|
7193
|
+
const isDocsAPIRequest = ${_optionalChain([config, 'access', _125 => _125.docs, 'optionalAccess', _126 => _126.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
|
|
7072
7194
|
const integrationMatch = ${hasServerRuntimeIntegrations ? `matchIntegrationRoute(serverRuntimeIntegrations, {
|
|
7073
7195
|
pathname,
|
|
7074
7196
|
method: request.method,
|
|
@@ -7158,7 +7280,7 @@ function getApplicableLayouts(pathname) {
|
|
|
7158
7280
|
return applicable;
|
|
7159
7281
|
}
|
|
7160
7282
|
|
|
7161
|
-
${_optionalChain([config, 'access',
|
|
7283
|
+
${_optionalChain([config, 'access', _127 => _127.docs, 'optionalAccess', _128 => _128.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
|
|
7162
7284
|
if (request.method === "HEAD") return response;
|
|
7163
7285
|
if (response.headers.get("x-farm-docs-adapter")) return response;
|
|
7164
7286
|
|
|
@@ -7265,7 +7387,7 @@ ${_optionalChain([config, 'access', _128 => _128.docs, 'optionalAccess', _129 =>
|
|
|
7265
7387
|
}` : ""}
|
|
7266
7388
|
|
|
7267
7389
|
const pprShellCache = getFarmDataCache();
|
|
7268
|
-
const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access',
|
|
7390
|
+
const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _129 => _129.experimental, 'optionalAccess', _130 => _130.ppr]) === true)};
|
|
7269
7391
|
|
|
7270
7392
|
function resolveRouteRenderingView(route) {
|
|
7271
7393
|
// The same merge development uses: baked directive config under the
|
|
@@ -7388,7 +7510,7 @@ async function handleFarmRequest(request, adapterContext) {
|
|
|
7388
7510
|
},
|
|
7389
7511
|
{ redirect: !isFarmLocalAPIPathname(requestUrl.pathname) }
|
|
7390
7512
|
)` : "handleFarmRequestInContext(request, null, false, Date.now(), adapterContext, requestUrl)"};
|
|
7391
|
-
${_optionalChain([config, 'access',
|
|
7513
|
+
${_optionalChain([config, 'access', _131 => _131.md, 'optionalAccess', _132 => _132.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
|
|
7392
7514
|
if (matchPageRoute(pathname)) {
|
|
7393
7515
|
// The Link header advertises the public .md URL, like the head alternate.
|
|
7394
7516
|
return applyMarkdownNegotiationHeaders(response, {
|
|
@@ -7423,7 +7545,7 @@ async function handleFarmRequestInContext(
|
|
|
7423
7545
|
url.search,
|
|
7424
7546
|
);
|
|
7425
7547
|
if (redirectMatch) {
|
|
7426
|
-
return
|
|
7548
|
+
return farmOwnedResponse("Redirecting to " + redirectMatch.destination, {
|
|
7427
7549
|
status: redirectMatch.statusCode,
|
|
7428
7550
|
headers: { Location: redirectMatch.destination },
|
|
7429
7551
|
});
|
|
@@ -7507,7 +7629,7 @@ async function handleFarmRequestInContext(
|
|
|
7507
7629
|
const middlewareHeaders = ${hasServerRuntimeIntegrations ? "withFarmIntegrationSetCookies(undefined, farmIntegrationSetCookies)" : "undefined"};
|
|
7508
7630
|
`}
|
|
7509
7631
|
|
|
7510
|
-
${_optionalChain([config, 'access',
|
|
7632
|
+
${_optionalChain([config, 'access', _133 => _133.docs, 'optionalAccess', _134 => _134.enabled]) ? `
|
|
7511
7633
|
// Docs responses are served after app middleware so route guards and
|
|
7512
7634
|
// middleware headers apply to the docs engine like any other page content.
|
|
7513
7635
|
// An app's own llms.txt, llms-full.txt, sitemap.xml, and robots.txt take
|
|
@@ -7527,7 +7649,7 @@ async function handleFarmRequestInContext(
|
|
|
7527
7649
|
);
|
|
7528
7650
|
const docsHeaders = new Headers(wrappedDocsResponse.headers);
|
|
7529
7651
|
docsHeaders.set("x-farm-preload-buffered", "1");
|
|
7530
|
-
return applyProductionMiddlewareHeaders(
|
|
7652
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(wrappedDocsResponse.body, {
|
|
7531
7653
|
status: wrappedDocsResponse.status,
|
|
7532
7654
|
statusText: wrappedDocsResponse.statusText,
|
|
7533
7655
|
headers: docsHeaders,
|
|
@@ -7552,7 +7674,7 @@ async function handleFarmRequestInContext(
|
|
|
7552
7674
|
}
|
|
7553
7675
|
` : ""}
|
|
7554
7676
|
|
|
7555
|
-
${_optionalChain([config, 'access',
|
|
7677
|
+
${_optionalChain([config, 'access', _135 => _135.md, 'optionalAccess', _136 => _136.enabled]) ? `
|
|
7556
7678
|
if (farmMarkdownConfig?.enabled) {
|
|
7557
7679
|
const markdownResponse = await createMarkdownMirrorResponse({
|
|
7558
7680
|
// The mirror helper only reads metadata and creates its own GET request.
|
|
@@ -7573,9 +7695,13 @@ async function handleFarmRequestInContext(
|
|
|
7573
7695
|
` : ""}
|
|
7574
7696
|
|
|
7575
7697
|
${apiRoutes.length > 0 ? `
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7698
|
+
// Clone only for an API request: cloning a Request costs more than the match,
|
|
7699
|
+
// and handleAPIRequest returns null without one.
|
|
7700
|
+
if (matchLocalAPIRequest(request)) {
|
|
7701
|
+
const apiResponse = await handleAPIRequest(cloneFarmRequestWithContext(request));
|
|
7702
|
+
if (apiResponse) {
|
|
7703
|
+
return applyProductionMiddlewareHeaders(apiResponse, middlewareHeaders);
|
|
7704
|
+
}
|
|
7579
7705
|
}
|
|
7580
7706
|
` : ""}
|
|
7581
7707
|
|
|
@@ -7586,7 +7712,7 @@ async function handleFarmRequestInContext(
|
|
|
7586
7712
|
) {
|
|
7587
7713
|
const method = request.method.toUpperCase();
|
|
7588
7714
|
const specResponse = method === "GET" || method === "HEAD"
|
|
7589
|
-
?
|
|
7715
|
+
? farmOwnedResponse(method === "HEAD" ? null : JSON.stringify(farmOpenAPIReference.spec), {
|
|
7590
7716
|
status: 200,
|
|
7591
7717
|
headers: {
|
|
7592
7718
|
"Content-Type": "application/json; charset=utf-8",
|
|
@@ -7594,7 +7720,7 @@ async function handleFarmRequestInContext(
|
|
|
7594
7720
|
"X-Content-Type-Options": "nosniff",
|
|
7595
7721
|
},
|
|
7596
7722
|
})
|
|
7597
|
-
:
|
|
7723
|
+
: farmOwnedResponse("Method Not Allowed", {
|
|
7598
7724
|
status: 405,
|
|
7599
7725
|
headers: {
|
|
7600
7726
|
"Allow": "GET, HEAD",
|
|
@@ -7610,7 +7736,7 @@ async function handleFarmRequestInContext(
|
|
|
7610
7736
|
) {
|
|
7611
7737
|
const method = request.method.toUpperCase();
|
|
7612
7738
|
const response = method === "GET" || method === "HEAD"
|
|
7613
|
-
?
|
|
7739
|
+
? farmOwnedResponse(method === "HEAD" ? null : farmOpenAPIReference.html, {
|
|
7614
7740
|
status: 200,
|
|
7615
7741
|
headers: {
|
|
7616
7742
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -7618,7 +7744,7 @@ async function handleFarmRequestInContext(
|
|
|
7618
7744
|
"X-Content-Type-Options": "nosniff",
|
|
7619
7745
|
},
|
|
7620
7746
|
})
|
|
7621
|
-
:
|
|
7747
|
+
: farmOwnedResponse("Method Not Allowed", {
|
|
7622
7748
|
status: 405,
|
|
7623
7749
|
headers: {
|
|
7624
7750
|
"Allow": "GET, HEAD",
|
|
@@ -7647,9 +7773,9 @@ async function handleFarmRequestInContext(
|
|
|
7647
7773
|
return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
|
|
7648
7774
|
}
|
|
7649
7775
|
` : ""}
|
|
7650
|
-
${_optionalChain([config, 'access',
|
|
7776
|
+
${_optionalChain([config, 'access', _137 => _137.agent, 'optionalAccess', _138 => _138.apiCatalog]) ? `
|
|
7651
7777
|
// agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
|
|
7652
|
-
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(
|
|
7778
|
+
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkNPPL5YDTcjs.FARM_API_CATALOG_PATH)}) {
|
|
7653
7779
|
return applyProductionMiddlewareHeaders(
|
|
7654
7780
|
createFarmApiCatalogResponse(request.method, farmApiCatalogInput, request),
|
|
7655
7781
|
middlewareHeaders,
|
|
@@ -7665,11 +7791,11 @@ async function handleFarmRequestInContext(
|
|
|
7665
7791
|
);
|
|
7666
7792
|
}
|
|
7667
7793
|
` : ""}
|
|
7668
|
-
${_optionalChain([config, 'access',
|
|
7794
|
+
${_optionalChain([config, 'access', _139 => _139.agent, 'optionalAccess', _140 => _140.llmsTxt, 'optionalAccess', _141 => _141.enabled]) ? `
|
|
7669
7795
|
// agent.llmsTxt with no llms.ts or llms-full.ts: serve the generated files.
|
|
7670
7796
|
const farmGeneratedLlmsKind = normalizeRuntimePath(routePathname) === "/llms.txt"
|
|
7671
7797
|
? "llms"
|
|
7672
|
-
: ${_optionalChain([config, 'access',
|
|
7798
|
+
: ${_optionalChain([config, 'access', _142 => _142.agent, 'optionalAccess', _143 => _143.llmsTxt, 'optionalAccess', _144 => _144.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
|
|
7673
7799
|
if (farmGeneratedLlmsKind) {
|
|
7674
7800
|
const llmsContext = createFarmLlmsTxtContext(request, farmGeneratedLlmsKind === "llms-full");
|
|
7675
7801
|
const llmsOrigin = new URL(request.url).origin;
|
|
@@ -7704,7 +7830,7 @@ async function handleFarmRequestInContext(
|
|
|
7704
7830
|
}
|
|
7705
7831
|
` : ""}
|
|
7706
7832
|
|
|
7707
|
-
${_optionalChain([config, 'access',
|
|
7833
|
+
${_optionalChain([config, 'access', _145 => _145.docs, 'optionalAccess', _146 => _146.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
|
|
7708
7834
|
const docsAPIResponse = await farmDocsAPIHandler(cloneFarmRequestWithContext(request));
|
|
7709
7835
|
if (docsAPIResponse) {
|
|
7710
7836
|
return applyProductionMiddlewareHeaders(docsAPIResponse, middlewareHeaders);
|
|
@@ -7713,7 +7839,7 @@ async function handleFarmRequestInContext(
|
|
|
7713
7839
|
|
|
7714
7840
|
// Preserve the explicit JSON 404 for misses below the configured local API path.
|
|
7715
7841
|
if (isFarmLocalAPIPathname(pathname)) {
|
|
7716
|
-
return applyProductionMiddlewareHeaders(
|
|
7842
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(
|
|
7717
7843
|
JSON.stringify({ error: "API route not found", pathname }),
|
|
7718
7844
|
{ status: 404, headers: { "Content-Type": "application/json" } }
|
|
7719
7845
|
), middlewareHeaders);
|
|
@@ -7729,7 +7855,7 @@ async function handleFarmRequestInContext(
|
|
|
7729
7855
|
);
|
|
7730
7856
|
if (trailingSlashLocation) {
|
|
7731
7857
|
return applyProductionMiddlewareHeaders(
|
|
7732
|
-
|
|
7858
|
+
farmOwnedResponse(null, {
|
|
7733
7859
|
status: 308,
|
|
7734
7860
|
headers: { Location: trailingSlashLocation },
|
|
7735
7861
|
}),
|
|
@@ -7772,7 +7898,7 @@ async function handleFarmRequestInContext(
|
|
|
7772
7898
|
status: 200,
|
|
7773
7899
|
durationMs: Date.now() - requestStartTime,
|
|
7774
7900
|
});
|
|
7775
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
7901
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(cachedPPRShell, {
|
|
7776
7902
|
status: 200,
|
|
7777
7903
|
headers: {
|
|
7778
7904
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -8079,7 +8205,7 @@ async function handleFarmRequestInContext(
|
|
|
8079
8205
|
}
|
|
8080
8206
|
|
|
8081
8207
|
wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
|
|
8082
|
-
return renderFarmElement(ReactDOMServer, wrappedElement);
|
|
8208
|
+
return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern);
|
|
8083
8209
|
};
|
|
8084
8210
|
const renderedPage = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
|
|
8085
8211
|
_runWithMiddlewareContext(middlewareContext, renderPageElement)
|
|
@@ -8139,7 +8265,7 @@ async function handleFarmRequestInContext(
|
|
|
8139
8265
|
);
|
|
8140
8266
|
}
|
|
8141
8267
|
}
|
|
8142
|
-
${_optionalChain([config, 'access',
|
|
8268
|
+
${_optionalChain([config, 'access', _147 => _147.md, 'optionalAccess', _148 => _148.enabled]) ? `
|
|
8143
8269
|
// Advertise the Markdown mirror in the head as well as the Link header,
|
|
8144
8270
|
// using the public path the .md request will be resolved against.
|
|
8145
8271
|
mergedMetadata = addMetadataMarkdownAlternate(
|
|
@@ -8147,7 +8273,7 @@ async function handleFarmRequestInContext(
|
|
|
8147
8273
|
getFarmMarkdownAlternatePath(farmMarkdownConfig, pathname),
|
|
8148
8274
|
);` : ""}
|
|
8149
8275
|
|
|
8150
|
-
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access',
|
|
8276
|
+
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _149 => _149.agent, 'optionalAccess', _150 => _150.jsonLd]), () => ( false)))} });
|
|
8151
8277
|
const title = renderedMetadata.title;
|
|
8152
8278
|
const metaTags = renderedMetadata.tags;
|
|
8153
8279
|
const hasFavicon = renderedMetadata.hasFavicon;
|
|
@@ -8267,7 +8393,7 @@ async function handleFarmRequestInContext(
|
|
|
8267
8393
|
});
|
|
8268
8394
|
}
|
|
8269
8395
|
);
|
|
8270
|
-
return applyProductionMiddlewareHeaders(
|
|
8396
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(streamedDocument, {
|
|
8271
8397
|
status: pageStatus,
|
|
8272
8398
|
headers: { ...responseHeaders, "x-farm-preload-streaming": "1" },
|
|
8273
8399
|
}), middlewareHeaders);
|
|
@@ -8408,7 +8534,7 @@ async function handleFarmRequestInContext(
|
|
|
8408
8534
|
durationMs: Date.now() - requestStartTime,
|
|
8409
8535
|
});
|
|
8410
8536
|
|
|
8411
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
8537
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(
|
|
8412
8538
|
fullHtml,
|
|
8413
8539
|
{
|
|
8414
8540
|
status: pageStatus,
|
|
@@ -8442,7 +8568,7 @@ async function handleFarmRequestInContext(
|
|
|
8442
8568
|
status: redirect.status,
|
|
8443
8569
|
durationMs: Date.now() - requestStartTime,
|
|
8444
8570
|
});
|
|
8445
|
-
return applyProductionMiddlewareHeaders(
|
|
8571
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(null, {
|
|
8446
8572
|
status: redirect.status,
|
|
8447
8573
|
headers: {
|
|
8448
8574
|
Location: redirectUrl,
|
|
@@ -8510,7 +8636,7 @@ async function handleFarmRequestInContext(
|
|
|
8510
8636
|
status: errorStatus,
|
|
8511
8637
|
durationMs: Date.now() - requestStartTime,
|
|
8512
8638
|
});
|
|
8513
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
8639
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(errorDocument, {
|
|
8514
8640
|
status: errorStatus,
|
|
8515
8641
|
headers: {
|
|
8516
8642
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -8545,7 +8671,7 @@ async function handleFarmRequestInContext(
|
|
|
8545
8671
|
farmResolvedRuntimeConfig.basePath,
|
|
8546
8672
|
getFarmTheme(request)
|
|
8547
8673
|
);
|
|
8548
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
8674
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(
|
|
8549
8675
|
fallbackDocument,
|
|
8550
8676
|
{
|
|
8551
8677
|
status: errorStatus,
|
|
@@ -8576,7 +8702,7 @@ async function handleFarmRequestInContext(
|
|
|
8576
8702
|
status: 404,
|
|
8577
8703
|
durationMs: Date.now() - requestStartTime,
|
|
8578
8704
|
});
|
|
8579
|
-
return applyProductionMiddlewareHeaders(
|
|
8705
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(
|
|
8580
8706
|
createFarmMarkdownErrorBody(404, pathname, applyFarmBasePath("/", farmResolvedRuntimeConfig.basePath)),
|
|
8581
8707
|
{
|
|
8582
8708
|
status: 404,
|
|
@@ -8673,7 +8799,7 @@ async function handleFarmRequestInContext(
|
|
|
8673
8799
|
durationMs: Date.now() - requestStartTime,
|
|
8674
8800
|
});
|
|
8675
8801
|
|
|
8676
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
8802
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(fullHtml, {
|
|
8677
8803
|
status: 404,
|
|
8678
8804
|
headers: {
|
|
8679
8805
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -8688,7 +8814,7 @@ async function handleFarmRequestInContext(
|
|
|
8688
8814
|
farmResolvedRuntimeConfig.basePath,
|
|
8689
8815
|
getFarmTheme(request)
|
|
8690
8816
|
);
|
|
8691
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(
|
|
8817
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(
|
|
8692
8818
|
fallbackDocument,
|
|
8693
8819
|
{
|
|
8694
8820
|
status: 404,
|
|
@@ -8751,22 +8877,22 @@ async function handleFarmPluginRequest(request, runtimeOptions, adapterContext)
|
|
|
8751
8877
|
headers.delete("content-length");
|
|
8752
8878
|
headers.delete("x-farm-preload-streaming");
|
|
8753
8879
|
headers.set("x-farm-preload-buffered", getFarmBufferedPreloadMarker(html));
|
|
8754
|
-
return
|
|
8880
|
+
return farmOwnedHtmlResponse(html, {
|
|
8755
8881
|
status: response.status,
|
|
8756
8882
|
statusText: response.statusText,
|
|
8757
8883
|
headers,
|
|
8758
|
-
})
|
|
8884
|
+
});
|
|
8759
8885
|
}
|
|
8760
8886
|
|
|
8761
8887
|
${generatePreloadResponseRuntimeSource()}
|
|
8762
8888
|
|
|
8763
8889
|
// Export as Web Standard fetch API
|
|
8764
8890
|
export async function fetch(request, context) {
|
|
8765
|
-
${_optionalChain([config, 'access',
|
|
8891
|
+
${_optionalChain([config, 'access', _151 => _151.agent, 'optionalAccess', _152 => _152.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
|
|
8766
8892
|
basePath: farmLocalAPIBasePath,
|
|
8767
8893
|
dispatch: async (localRequest) =>
|
|
8768
8894
|
(await handleAPIRequest(localRequest)) ?? Response.json({ error: "Not Found" }, { status: 404 }),
|
|
8769
|
-
}, () => handleFarmFetch(request, context));${_optionalChain([config, 'access',
|
|
8895
|
+
}, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _153 => _153.agent, 'optionalAccess', _154 => _154.noindexPreviews]) ? `
|
|
8770
8896
|
// Keep every response of a preview deployment out of search indexes.
|
|
8771
8897
|
return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
|
|
8772
8898
|
}
|
|
@@ -8832,7 +8958,7 @@ async function handleFarmFetch(request, context) {
|
|
|
8832
8958
|
const response = await _runWithCurrentRequest(request, () =>
|
|
8833
8959
|
_runWithAfterRequest(request, runRequest, context),
|
|
8834
8960
|
);
|
|
8835
|
-
return ${hasCompressionRuntime && !hasPluginRuntime ? "compressFarmResponse(request, response, getFarmOwnedBufferedHtml(response))" : "response"};
|
|
8961
|
+
return ${hasCompressionRuntime && !hasPluginRuntime ? "compressFarmResponse(request, response, getFarmOwnedBufferedHtml(response), farmLazyBufferedHtml.has(response))" : "response"};
|
|
8836
8962
|
}),
|
|
8837
8963
|
{
|
|
8838
8964
|
onResponseFinished: typeof context?.onResponseFinished === "function"
|
|
@@ -8841,7 +8967,7 @@ async function handleFarmFetch(request, context) {
|
|
|
8841
8967
|
},
|
|
8842
8968
|
);
|
|
8843
8969
|
}
|
|
8844
|
-
export { createFarmNodeRequestAbortSignal };
|
|
8970
|
+
export { createFarmNodeRequestAbortSignal, getFarmOwnedBufferedHtml, useFarmNodePageResponse };
|
|
8845
8971
|
export default { fetch, lifecycle: farmProductionLifecycle };
|
|
8846
8972
|
`.trim();
|
|
8847
8973
|
}
|
|
@@ -8909,7 +9035,7 @@ function configMiddlewareMayHandlePath(config, pathname) {
|
|
|
8909
9035
|
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
8910
9036
|
const entries = Array.isArray(config) ? config : [config];
|
|
8911
9037
|
return entries.some((entry) => {
|
|
8912
|
-
if (_optionalChain([entry, 'access',
|
|
9038
|
+
if (_optionalChain([entry, 'access', _155 => _155.exclude, 'optionalAccess', _156 => _156.some, 'call', _157 => _157((pattern) => middlewarePatternMatches(pattern, pathname))])) {
|
|
8913
9039
|
return false;
|
|
8914
9040
|
}
|
|
8915
9041
|
if (!entry.matcher) return true;
|
|
@@ -8965,11 +9091,11 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
8965
9091
|
}
|
|
8966
9092
|
if (appMiddlewareMayHandlePath(middlewareRoutes, pathname)) return "app middleware";
|
|
8967
9093
|
if (configMiddlewareMayHandlePath(config.middleware, pathname)) return "configured middleware";
|
|
8968
|
-
if (
|
|
9094
|
+
if (_chunkJFHKNFEOcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
|
|
8969
9095
|
if (farmServerRuntimePluginsMayHandlePath(config, pathname)) return "server runtime plugin";
|
|
8970
9096
|
const manifestEntry = getManifestPageEntry(routeRuntimeManifest, pathname);
|
|
8971
|
-
if (_optionalChain([manifestEntry, 'optionalAccess',
|
|
8972
|
-
if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access',
|
|
9097
|
+
if (_optionalChain([manifestEntry, 'optionalAccess', _158 => _158.rendering]) === "dynamic") return "dynamic runtime manifest";
|
|
9098
|
+
if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _159 => _159.regions, 'optionalAccess', _160 => _160.length])) || manifestEntry.maxDuration !== void 0)) {
|
|
8973
9099
|
return "route runtime controls";
|
|
8974
9100
|
}
|
|
8975
9101
|
const routeRule = getEffectiveRouteRule(config, pathname);
|
|
@@ -8991,7 +9117,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
8991
9117
|
const nitroBuilder = nitroBuilderResult.value;
|
|
8992
9118
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
8993
9119
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
8994
|
-
const outputDir =
|
|
9120
|
+
const outputDir = _chunkJFHKNFEOcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
8995
9121
|
const runtimeServerOutputDir = isVercel ? _path2.default.join(outputDir, "functions", "__nitro.func") : _path2.default.join(outputDir, "server");
|
|
8996
9122
|
const ssrOutputDir = _path2.default.join(root, distDir, "ssr");
|
|
8997
9123
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
@@ -9082,12 +9208,16 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9082
9208
|
await fs.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9083
9209
|
}
|
|
9084
9210
|
const nitroEntryPath = _path2.default.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9211
|
+
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
9085
9212
|
const nitroEntryCode = `
|
|
9086
9213
|
// Farm.js Nitro Entry
|
|
9087
9214
|
// This file adapts Farm's Web fetch handler to Nitro's event handler contract.
|
|
9088
9215
|
|
|
9089
9216
|
import { useNitroHooks } from '#nitro/runtime/app'
|
|
9090
|
-
import handler, { farmProductionLifecycle, createFarmNodeRequestAbortSignal } from './${ssrEntryFile}'
|
|
9217
|
+
import handler, { farmProductionLifecycle, createFarmNodeRequestAbortSignal${nodeAdapterModule ? ", getFarmOwnedBufferedHtml, useFarmNodePageResponse" : ""} } from './${ssrEntryFile}'${nodeAdapterModule ? `
|
|
9218
|
+
import { FastResponse } from ${JSON.stringify(nodeAdapterModule)}
|
|
9219
|
+
|
|
9220
|
+
useFarmNodePageResponse(FastResponse)` : ""}
|
|
9091
9221
|
|
|
9092
9222
|
export { farmProductionLifecycle }
|
|
9093
9223
|
|
|
@@ -9183,11 +9313,14 @@ function resolveTrustedLocalOrigin(event, request) {
|
|
|
9183
9313
|
// Export the event handler for Nitro
|
|
9184
9314
|
export default async function farmNitroEventHandler(event) {
|
|
9185
9315
|
registerFarmCloseHook()
|
|
9186
|
-
//
|
|
9187
|
-
//
|
|
9316
|
+
// Abort only on an actual disconnect, the same events as Farm's development
|
|
9317
|
+
// server. srvx's Request already aborts that way (on a response close before
|
|
9318
|
+
// it ended, never on a normal IncomingMessage close), so use it as is. Other
|
|
9319
|
+
// Node adapters get a copy with Farm's own signal.
|
|
9188
9320
|
const node = event.node
|
|
9189
|
-
const
|
|
9190
|
-
const
|
|
9321
|
+
const srvxRequest = event.req?._request
|
|
9322
|
+
const webRequest = srvxRequest || event.req
|
|
9323
|
+
const request = !srvxRequest && node?.req && node?.res
|
|
9191
9324
|
? new Request(webRequest, { signal: createFarmNodeRequestAbortSignal(node.req, node.res) })
|
|
9192
9325
|
: webRequest
|
|
9193
9326
|
const response = await handler.fetch(request, {
|
|
@@ -9198,20 +9331,42 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9198
9331
|
})
|
|
9199
9332
|
|
|
9200
9333
|
// Nitro records asset compression negotiation on the event response. Merge
|
|
9201
|
-
// Farm's cache signals there so H3 preserves both sets of Vary values.
|
|
9334
|
+
// Farm's cache signals there so H3 preserves both sets of Vary values. Only
|
|
9335
|
+
// merge into a Vary Nitro set: any event header makes H3 rebuild the response
|
|
9336
|
+
// around its body, and without one H3 keeps Farm's Vary as it is.
|
|
9202
9337
|
const farmVary = response.headers.get('Vary')
|
|
9203
|
-
if (farmVary)
|
|
9204
|
-
|
|
9205
|
-
|
|
9338
|
+
if (farmVary) {
|
|
9339
|
+
const nitroHeaders = event.res.headers
|
|
9340
|
+
if (nitroHeaders.has('Vary')) mergeVaryHeaders(nitroHeaders, farmVary)
|
|
9341
|
+
}
|
|
9342
|
+
return ${nodeAdapterModule ? "toFarmNodeResponse(request, response)" : "response"}
|
|
9343
|
+
}${nodeAdapterModule ? `
|
|
9344
|
+
|
|
9345
|
+
// A page Farm still holds as one complete string is sent in a single write with
|
|
9346
|
+
// Content-Length, instead of srvx reading the Web stream chunk by chunk. Any
|
|
9347
|
+
// step that read, cloned or replaced the body made a new stream, so its lookup
|
|
9348
|
+
// misses and that response is sent as it is.
|
|
9349
|
+
function toFarmNodeResponse(request, response) {
|
|
9350
|
+
if (request.method === 'HEAD') return response
|
|
9351
|
+
// Already a FastResponse (a buffered page built as one): srvx sends it as is.
|
|
9352
|
+
if (typeof response._toNodeResponse === 'function') return response
|
|
9353
|
+
const html = getFarmOwnedBufferedHtml(response)
|
|
9354
|
+
if (html === undefined) return response
|
|
9355
|
+
return new FastResponse(html, {
|
|
9356
|
+
status: response.status,
|
|
9357
|
+
statusText: response.statusText,
|
|
9358
|
+
headers: response.headers,
|
|
9359
|
+
})
|
|
9360
|
+
}` : ""}
|
|
9206
9361
|
`.trim();
|
|
9207
9362
|
await fs.writeFile(nitroEntryPath, nitroEntryCode);
|
|
9208
9363
|
const farmNodeServerEntryPath = preset === "node-server" ? _path2.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9209
|
-
if (farmNodeServerEntryPath) {
|
|
9364
|
+
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9210
9365
|
await fs.writeFile(
|
|
9211
9366
|
farmNodeServerEntryPath,
|
|
9212
9367
|
createFarmNodeServerEntry({
|
|
9213
9368
|
nitroEntryFile: _path2.default.basename(nitroEntryPath),
|
|
9214
|
-
nodeAdapterModule
|
|
9369
|
+
nodeAdapterModule,
|
|
9215
9370
|
server: config.server,
|
|
9216
9371
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
9217
9372
|
})
|
|
@@ -9302,7 +9457,13 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9302
9457
|
},
|
|
9303
9458
|
rollupConfig: {
|
|
9304
9459
|
external: nitroRollupExternal,
|
|
9305
|
-
plugins:
|
|
9460
|
+
plugins: [
|
|
9461
|
+
...hasGeneratedMetadataImages && !useExternalMetadataImageRuntime ? [createMetadataImageWasmPlugin()] : [],
|
|
9462
|
+
// Workers bundle React here rather than loading it from node_modules.
|
|
9463
|
+
// Unenv rewrites `process` before Nitro's own replacements run, so
|
|
9464
|
+
// React's development builds would otherwise ship next to production.
|
|
9465
|
+
...isCloudflareWorker ? [createReactProductionModePlugin()] : []
|
|
9466
|
+
]
|
|
9306
9467
|
},
|
|
9307
9468
|
// Keep the public Nitro boolean intact for build hooks. Farm replaces
|
|
9308
9469
|
// Nitro's minifier only when no custom OXC transform was requested.
|
|
@@ -9327,20 +9488,20 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9327
9488
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
9328
9489
|
);
|
|
9329
9490
|
const requestedBuilder = _nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER));
|
|
9330
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access',
|
|
9331
|
-
_optionalChain([nitroConfig, 'access',
|
|
9332
|
-
(handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess',
|
|
9491
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _161 => _161.rollupConfig, 'optionalAccess', _162 => _162.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _163 => _163.rollupConfig, 'optionalAccess', _164 => _164.plugins])) && customRollupKeys.length === 0 && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _165 => _165.output, 'optionalAccess', _166 => _166.serverDir]) || "") === _path2.default.resolve(expectedServerDir) && Boolean(
|
|
9492
|
+
_optionalChain([nitroConfig, 'access', _167 => _167.handlers, 'optionalAccess', _168 => _168.some, 'call', _169 => _169(
|
|
9493
|
+
(handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _170 => _170.handler]) || "") === nitroEntryPath
|
|
9333
9494
|
)])
|
|
9334
9495
|
);
|
|
9335
9496
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
9336
9497
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
9337
9498
|
const useRolldownBuilder = canReusePrebuiltSSR && (_nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER))) === "rolldown";
|
|
9338
9499
|
const shouldMinify = nitroConfig.minify !== false;
|
|
9339
|
-
const keepServerNames = !(_optionalChain([config, 'access',
|
|
9500
|
+
const keepServerNames = !(_optionalChain([config, 'access', _171 => _171.docs, 'optionalAccess', _172 => _172.enabled]) && _optionalChain([config, 'access', _173 => _173.docs, 'access', _174 => _174.adapter, 'optionalAccess', _175 => _175.server]));
|
|
9340
9501
|
const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
|
|
9341
9502
|
const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
|
|
9342
9503
|
if (canReusePrebuiltSSR) {
|
|
9343
|
-
const configuredRollupPlugins = _optionalChain([nitroConfig, 'access',
|
|
9504
|
+
const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _176 => _176.rollupConfig, 'optionalAccess', _177 => _177.plugins]);
|
|
9344
9505
|
nitroConfig.rollupConfig = {
|
|
9345
9506
|
...nitroConfig.rollupConfig,
|
|
9346
9507
|
plugins: [
|
|
@@ -9351,10 +9512,10 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9351
9512
|
}
|
|
9352
9513
|
nitroConfig.minify = useFarmServerMinifier ? false : shouldMinify;
|
|
9353
9514
|
const nitroInstance = await nitroBuilder.createNitro(nitroConfig);
|
|
9354
|
-
if (_optionalChain([config, 'access',
|
|
9515
|
+
if (_optionalChain([config, 'access', _178 => _178.md, 'optionalAccess', _179 => _179.enabled])) {
|
|
9355
9516
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
9356
|
-
if (!route.contents || !_optionalChain([route, 'access',
|
|
9357
|
-
const alternatePath =
|
|
9517
|
+
if (!route.contents || !_optionalChain([route, 'access', _180 => _180.contentType, 'optionalAccess', _181 => _181.toLowerCase, 'call', _182 => _182(), 'access', _183 => _183.includes, 'call', _184 => _184("html")])) return;
|
|
9518
|
+
const alternatePath = _chunk6CNX6Q3Kcjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route);
|
|
9358
9519
|
if (!alternatePath) return;
|
|
9359
9520
|
const routeRule = nitroInstance.options.routeRules[route.route] || {};
|
|
9360
9521
|
const alternate = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
|
|
@@ -9374,8 +9535,8 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9374
9535
|
}
|
|
9375
9536
|
if (config.security.csp && config.security.csp.nonce) {
|
|
9376
9537
|
nitroInstance.hooks.hook("prerender:generate", async (route) => {
|
|
9377
|
-
if (!route.contents || !_optionalChain([route, 'access',
|
|
9378
|
-
const staticCsp = await
|
|
9538
|
+
if (!route.contents || !_optionalChain([route, 'access', _185 => _185.contentType, 'optionalAccess', _186 => _186.toLowerCase, 'call', _187 => _187(), 'access', _188 => _188.includes, 'call', _189 => _189("html")])) return;
|
|
9539
|
+
const staticCsp = await _chunkXLTV4VOGcjs.applyFarmCspHashesToHtml.call(void 0, route.contents, config.security);
|
|
9379
9540
|
if (!staticCsp) return;
|
|
9380
9541
|
route.contents = staticCsp.html;
|
|
9381
9542
|
const routeRule = nitroInstance.options.routeRules[route.route] || {};
|
|
@@ -9582,7 +9743,7 @@ async function moveVercelOutputPath(src, dest, fs) {
|
|
|
9582
9743
|
await fs.rename(src, dest);
|
|
9583
9744
|
return;
|
|
9584
9745
|
} catch (error) {
|
|
9585
|
-
const code = _optionalChain([error, 'optionalAccess',
|
|
9746
|
+
const code = _optionalChain([error, 'optionalAccess', _190 => _190.code]);
|
|
9586
9747
|
if (code !== "EPERM" && code !== "EACCES" && code !== "EXDEV" && code !== "ENOTEMPTY") {
|
|
9587
9748
|
throw error;
|
|
9588
9749
|
}
|
|
@@ -9609,7 +9770,7 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
|
|
|
9609
9770
|
try {
|
|
9610
9771
|
await moveVercelOutputPath(publicDir, staticDir, fs);
|
|
9611
9772
|
} catch (error) {
|
|
9612
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
9773
|
+
if (_optionalChain([error, 'optionalAccess', _191 => _191.code]) !== "ENOENT") throw error;
|
|
9613
9774
|
}
|
|
9614
9775
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs);
|
|
9615
9776
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs);
|
|
@@ -9642,7 +9803,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
|
|
|
9642
9803
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
9643
9804
|
if (!docsContentDir) return;
|
|
9644
9805
|
const bundledContentDir = _path2.default.join(nitroFuncDir, "farm-docs-content");
|
|
9645
|
-
const lastModifiedManifest =
|
|
9806
|
+
const lastModifiedManifest = _chunkQ5JFU33Qcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
|
|
9646
9807
|
fallback: "now"
|
|
9647
9808
|
});
|
|
9648
9809
|
await fs.rm(bundledContentDir, { recursive: true, force: true });
|
|
@@ -9652,7 +9813,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
|
|
|
9652
9813
|
force: true
|
|
9653
9814
|
});
|
|
9654
9815
|
await fs.writeFile(
|
|
9655
|
-
_path2.default.join(bundledContentDir,
|
|
9816
|
+
_path2.default.join(bundledContentDir, _chunkQ5JFU33Qcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
9656
9817
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
9657
9818
|
`
|
|
9658
9819
|
);
|
|
@@ -9729,7 +9890,7 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9729
9890
|
try {
|
|
9730
9891
|
await copyPackage("sharp", sharpRequire);
|
|
9731
9892
|
if (!copiedPackages.has("sharp")) {
|
|
9732
|
-
throw new Error(`Farm image optimization requires sharp. ${
|
|
9893
|
+
throw new Error(`Farm image optimization requires sharp. ${_chunkGIWC4CFJcjs.SHARP_INSTALL_HINT}`);
|
|
9733
9894
|
}
|
|
9734
9895
|
} catch (error) {
|
|
9735
9896
|
await fs.rm(stageDir, { recursive: true, force: true });
|
|
@@ -9943,7 +10104,7 @@ function createBuildTargetBaseline(config) {
|
|
|
9943
10104
|
preset,
|
|
9944
10105
|
distDir,
|
|
9945
10106
|
outputDir,
|
|
9946
|
-
outputWasDerived: outputDir ===
|
|
10107
|
+
outputWasDerived: outputDir === _chunkJFHKNFEOcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
|
|
9947
10108
|
};
|
|
9948
10109
|
}
|
|
9949
10110
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createBuildTargetBaseline, "createBuildTargetBaseline");
|
|
@@ -9953,8 +10114,8 @@ function resolveBuildTargets(config, options, baseline) {
|
|
|
9953
10114
|
const distDir = config.distDir || ".farm";
|
|
9954
10115
|
const outputWasReplaced = config.deploy.outputDir !== baseline.outputDir;
|
|
9955
10116
|
const shouldRefreshDerivedOutput = baseline.outputWasDerived && !outputWasReplaced && (preset !== baseline.preset || distDir !== baseline.distDir);
|
|
9956
|
-
const deployTarget = preset === config.deploy.preset ? config.deploy.target :
|
|
9957
|
-
const outputDir = shouldRefreshDerivedOutput ?
|
|
10117
|
+
const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkJFHKNFEOcjs.getDeployTargetForPreset.call(void 0, preset);
|
|
10118
|
+
const outputDir = shouldRefreshDerivedOutput ? _chunkJFHKNFEOcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
|
|
9958
10119
|
return {
|
|
9959
10120
|
root,
|
|
9960
10121
|
preset,
|
|
@@ -9962,7 +10123,7 @@ function resolveBuildTargets(config, options, baseline) {
|
|
|
9962
10123
|
distDir,
|
|
9963
10124
|
deployTarget,
|
|
9964
10125
|
outputDir,
|
|
9965
|
-
deployOutputDir:
|
|
10126
|
+
deployOutputDir: _chunkJFHKNFEOcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
|
|
9966
10127
|
};
|
|
9967
10128
|
}
|
|
9968
10129
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveBuildTargets, "resolveBuildTargets");
|
|
@@ -9971,7 +10132,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
9971
10132
|
const targetBaseline = createBuildTargetBaseline(config);
|
|
9972
10133
|
let targets;
|
|
9973
10134
|
const productionViteResultPromise = options.universal === false ? void 0 : Promise.allSettled([Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))]);
|
|
9974
|
-
const pluginManager = new (0,
|
|
10135
|
+
const pluginManager = new (0, _chunkGIWC4CFJcjs.PluginManager)({
|
|
9975
10136
|
config,
|
|
9976
10137
|
isDev: false,
|
|
9977
10138
|
isProd: true
|
|
@@ -10000,12 +10161,12 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10000
10161
|
};
|
|
10001
10162
|
config = {
|
|
10002
10163
|
...config,
|
|
10003
|
-
images:
|
|
10164
|
+
images: _chunkGIWC4CFJcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
|
|
10004
10165
|
root: targets.root,
|
|
10005
10166
|
preset: targets.preset
|
|
10006
10167
|
})
|
|
10007
10168
|
};
|
|
10008
|
-
if (_optionalChain([config, 'access',
|
|
10169
|
+
if (_optionalChain([config, 'access', _192 => _192.docs, 'optionalAccess', _193 => _193.enabled])) await _chunkIK6LVLKCcjs.loadFarmDocsEngine.call(void 0, );
|
|
10009
10170
|
pluginManager.updateContext({ config });
|
|
10010
10171
|
const { root, preset, srcDir, distDir, deployOutputDir } = targets;
|
|
10011
10172
|
_chunk5QIKR7RRcjs.logger.info(`\u{1F69C} Building Farm.js application with preset: ${preset}...`);
|
|
@@ -10019,8 +10180,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10019
10180
|
});
|
|
10020
10181
|
_chunk5QIKR7RRcjs.logger.info("\u{1F50D} Discovering routes and API endpoints...");
|
|
10021
10182
|
const productionViteResult = productionViteResultPromise ? (await productionViteResultPromise)[0] : void 0;
|
|
10022
|
-
if (_optionalChain([productionViteResult, 'optionalAccess',
|
|
10023
|
-
const productionVite = _optionalChain([productionViteResult, 'optionalAccess',
|
|
10183
|
+
if (_optionalChain([productionViteResult, 'optionalAccess', _194 => _194.status]) === "rejected") throw productionViteResult.reason;
|
|
10184
|
+
const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _195 => _195.value]);
|
|
10024
10185
|
const createViteServer = productionVite ? productionVite.createServer : (await import("vite")).createServer;
|
|
10025
10186
|
projectModuleServer = await createProjectModuleServer(
|
|
10026
10187
|
createViteServer,
|
|
@@ -10028,7 +10189,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10028
10189
|
root,
|
|
10029
10190
|
rendererBuild.signal
|
|
10030
10191
|
);
|
|
10031
|
-
const farmApp =
|
|
10192
|
+
const farmApp = _chunkGIWC4CFJcjs.createFarmApp.call(void 0, config, projectModuleServer);
|
|
10032
10193
|
await farmApp.initialize();
|
|
10033
10194
|
const routeManager = farmApp.getRouteManager();
|
|
10034
10195
|
const serverRenderer = farmApp.getServerRenderer();
|
|
@@ -10038,8 +10199,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10038
10199
|
layers: config.layers,
|
|
10039
10200
|
plugins: config.plugins,
|
|
10040
10201
|
extraRoutes: [
|
|
10041
|
-
..._optionalChain([config, 'access',
|
|
10042
|
-
...
|
|
10202
|
+
..._optionalChain([config, 'access', _196 => _196.openapi, 'optionalAccess', _197 => _197.enabled]) && config.openapi.route ? [config.openapi.route] : [],
|
|
10203
|
+
..._chunkQ5JFU33Qcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
|
|
10043
10204
|
],
|
|
10044
10205
|
suppressLintOnLink: config.suppressLintOnLink,
|
|
10045
10206
|
componentExtensions: config.renderer.componentExtensions,
|
|
@@ -10123,7 +10284,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10123
10284
|
throw error;
|
|
10124
10285
|
} finally {
|
|
10125
10286
|
try {
|
|
10126
|
-
await _optionalChain([projectModuleServer, 'optionalAccess',
|
|
10287
|
+
await _optionalChain([projectModuleServer, 'optionalAccess', _198 => _198.close, 'call', _199 => _199()]);
|
|
10127
10288
|
} finally {
|
|
10128
10289
|
rendererBuild.abort();
|
|
10129
10290
|
}
|
|
@@ -10135,7 +10296,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10135
10296
|
ssr: true,
|
|
10136
10297
|
buildLifetime
|
|
10137
10298
|
});
|
|
10138
|
-
const viteConfig =
|
|
10299
|
+
const viteConfig = _chunkGIWC4CFJcjs.mergeFarmViteConfig.call(void 0,
|
|
10139
10300
|
{
|
|
10140
10301
|
root,
|
|
10141
10302
|
appType: "custom",
|
|
@@ -10147,7 +10308,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10147
10308
|
},
|
|
10148
10309
|
plugins: [
|
|
10149
10310
|
...rendererVitePlugins,
|
|
10150
|
-
|
|
10311
|
+
_chunkGIWC4CFJcjs.farmFontImportsPlugin.call(void 0, {
|
|
10151
10312
|
root,
|
|
10152
10313
|
basePath: config.basePath,
|
|
10153
10314
|
publicDir: config.publicDir
|
|
@@ -10159,7 +10320,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
10159
10320
|
hmr: false
|
|
10160
10321
|
},
|
|
10161
10322
|
resolve: {
|
|
10162
|
-
alias:
|
|
10323
|
+
alias: _chunkGIWC4CFJcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
|
|
10163
10324
|
dedupe: [...config.renderer.dedupe || []]
|
|
10164
10325
|
},
|
|
10165
10326
|
optimizeDeps: {
|
|
@@ -10245,7 +10406,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
10245
10406
|
define: {
|
|
10246
10407
|
__FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
|
|
10247
10408
|
__FARM_ENV__: JSON.stringify(_chunkVEKFLAQMcjs.createBundledEnv.call(void 0, config.env)),
|
|
10248
|
-
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access',
|
|
10409
|
+
__FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _200 => _200.env, 'optionalAccess', _201 => _201.public]) || {})
|
|
10249
10410
|
},
|
|
10250
10411
|
plugins: [
|
|
10251
10412
|
farmI18nClientBridgePlugin(),
|
|
@@ -10280,7 +10441,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10280
10441
|
if (pluginManager) {
|
|
10281
10442
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
10282
10443
|
}
|
|
10283
|
-
const outputDir =
|
|
10444
|
+
const outputDir = _chunkJFHKNFEOcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
|
|
10284
10445
|
const serverOutputDir = _path2.default.join(outputDir, "server");
|
|
10285
10446
|
const publicOutputDir = _path2.default.join(outputDir, "public");
|
|
10286
10447
|
const { mkdir, cp } = await import("fs/promises");
|
|
@@ -10351,7 +10512,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10351
10512
|
root,
|
|
10352
10513
|
preset,
|
|
10353
10514
|
distDir,
|
|
10354
|
-
outputDir:
|
|
10515
|
+
outputDir: _chunkJFHKNFEOcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
|
|
10355
10516
|
});
|
|
10356
10517
|
}
|
|
10357
10518
|
}
|