@farm.js/core 0.1.0-beta.33 → 0.1.0-beta.34
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/{chunk-GKEYR7EK.mjs → chunk-4EHFJHPN.mjs} +2 -2
- package/dist/{chunk-GKEYR7EK.mjs.map → chunk-4EHFJHPN.mjs.map} +1 -1
- package/dist/{chunk-EL644GWT.mjs → chunk-7JLDC7IO.mjs} +17 -4
- package/dist/chunk-7JLDC7IO.mjs.map +1 -0
- package/dist/{chunk-QGRLI3KV.mjs → chunk-AVP2HHCL.mjs} +2 -2
- package/dist/{chunk-5PDVNNUQ.mjs → chunk-BNTDKO7T.mjs} +8 -4
- package/dist/chunk-BNTDKO7T.mjs.map +1 -0
- package/dist/{chunk-DV5ZT2JO.mjs → chunk-DGEPZFH3.mjs} +4 -4
- package/dist/{chunk-NETDSCXV.mjs → chunk-IU42657J.mjs} +2 -2
- package/dist/{chunk-4TI6B4AY.mjs → chunk-UMGOTX4G.mjs} +220 -154
- package/dist/chunk-UMGOTX4G.mjs.map +1 -0
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.cjs.map +1 -1
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +2 -2
- package/dist/{devtools-BF6URGGF.mjs → devtools-G4S3JRIH.mjs} +3 -3
- package/dist/docs.cjs +13 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +3 -3
- package/dist/index.cjs +437 -352
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/internal/build-runtime.cjs +414 -329
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +6 -6
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/internal/config-runtime.cjs +17 -3
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/plugin.cjs +16 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +3 -3
- package/dist/renderer.cjs +7 -3
- package/dist/renderer.cjs.map +1 -1
- package/dist/renderer.d.mts +9 -0
- package/dist/renderer.d.ts +9 -0
- package/dist/renderer.mjs +1 -1
- package/dist/server.cjs +23 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +4 -4
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +21 -5
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +3 -3
- package/package.json +3 -3
- package/dist/chunk-4TI6B4AY.mjs.map +0 -1
- package/dist/chunk-5PDVNNUQ.mjs.map +0 -1
- package/dist/chunk-EL644GWT.mjs.map +0 -1
- /package/dist/{chunk-QGRLI3KV.mjs.map → chunk-AVP2HHCL.mjs.map} +0 -0
- /package/dist/{chunk-DV5ZT2JO.mjs.map → chunk-DGEPZFH3.mjs.map} +0 -0
- /package/dist/{chunk-NETDSCXV.mjs.map → chunk-IU42657J.mjs.map} +0 -0
- /package/dist/{devtools-BF6URGGF.mjs.map → devtools-G4S3JRIH.mjs.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -70,7 +70,8 @@ function resolveFarmRenderer(renderer) {
|
|
|
70
70
|
dedupe: [...resolved.dedupe || []],
|
|
71
71
|
optimizeDeps: [...resolved.optimizeDeps || []],
|
|
72
72
|
buildConcurrency: resolved.buildConcurrency || "parallel",
|
|
73
|
-
capabilities: getFarmRendererCapabilities(resolved)
|
|
73
|
+
capabilities: getFarmRendererCapabilities(resolved),
|
|
74
|
+
options: resolved.options ? { ...resolved.options } : void 0
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
async function readFarmRendererWebStream(stream) {
|
|
@@ -92,7 +93,7 @@ function resolveFarmRendererModule(root, specifier) {
|
|
|
92
93
|
return requireFromApp.resolve(specifier);
|
|
93
94
|
}
|
|
94
95
|
async function loadFarmRendererVitePlugins(renderer, root, options = {}) {
|
|
95
|
-
if (
|
|
96
|
+
if (renderer.vite === REACT_RENDERER.vite) return [];
|
|
96
97
|
const modulePath = resolveFarmRendererModule(root, renderer.vite);
|
|
97
98
|
const rendererModule = await import((0, import_node_url.pathToFileURL)(modulePath).href);
|
|
98
99
|
if (typeof rendererModule.createFarmRendererPlugin !== "function") {
|
|
@@ -100,7 +101,10 @@ async function loadFarmRendererVitePlugins(renderer, root, options = {}) {
|
|
|
100
101
|
`Renderer \`${renderer.name}\` module ${renderer.vite} must export createFarmRendererPlugin().`
|
|
101
102
|
);
|
|
102
103
|
}
|
|
103
|
-
const created = await rendererModule.createFarmRendererPlugin(
|
|
104
|
+
const created = await rendererModule.createFarmRendererPlugin({
|
|
105
|
+
...options,
|
|
106
|
+
rendererOptions: renderer.options
|
|
107
|
+
});
|
|
104
108
|
if (!created) return [];
|
|
105
109
|
return Array.isArray(created) ? [...created] : [created];
|
|
106
110
|
}
|
|
@@ -787,13 +791,13 @@ function defineIntegrationAPI(api3) {
|
|
|
787
791
|
}
|
|
788
792
|
function operation(method, pathOrOptions, maybeOptions = {}) {
|
|
789
793
|
const hasExplicitPath = typeof pathOrOptions === "string";
|
|
790
|
-
const
|
|
794
|
+
const path38 = hasExplicitPath ? pathOrOptions : "";
|
|
791
795
|
const options = hasExplicitPath ? maybeOptions : {
|
|
792
796
|
...maybeOptions,
|
|
793
797
|
...pathOrOptions
|
|
794
798
|
};
|
|
795
799
|
return defineIntegrationAPIOperation({
|
|
796
|
-
path:
|
|
800
|
+
path: path38,
|
|
797
801
|
method,
|
|
798
802
|
__pathless: !hasExplicitPath,
|
|
799
803
|
...options
|
|
@@ -805,26 +809,26 @@ function get(pathOrOptions, maybeOptions = {}) {
|
|
|
805
809
|
function isOperation(value) {
|
|
806
810
|
return !!value && typeof value === "object" && value.kind === "farm-integration-api-operation";
|
|
807
811
|
}
|
|
808
|
-
function bindRoutePath(
|
|
812
|
+
function bindRoutePath(path38, api3) {
|
|
809
813
|
const entries = Object.entries(api3).map(([key, value]) => {
|
|
810
814
|
if (isOperation(value)) {
|
|
811
815
|
return [
|
|
812
816
|
key,
|
|
813
817
|
{
|
|
814
818
|
...value,
|
|
815
|
-
path:
|
|
819
|
+
path: path38,
|
|
816
820
|
__pathless: false
|
|
817
821
|
}
|
|
818
822
|
];
|
|
819
823
|
}
|
|
820
824
|
if (value && typeof value === "object") {
|
|
821
|
-
return [key, bindRoutePath(
|
|
825
|
+
return [key, bindRoutePath(path38, value)];
|
|
822
826
|
}
|
|
823
827
|
return [key, value];
|
|
824
828
|
});
|
|
825
829
|
return Object.fromEntries(entries);
|
|
826
830
|
}
|
|
827
|
-
function route(
|
|
831
|
+
function route(path38, definitionOrOperation, ...operations) {
|
|
828
832
|
if (isOperation(definitionOrOperation)) {
|
|
829
833
|
const allOperations = [definitionOrOperation, ...operations];
|
|
830
834
|
return Object.fromEntries(
|
|
@@ -832,13 +836,13 @@ function route(path37, definitionOrOperation, ...operations) {
|
|
|
832
836
|
operation2.method.toLowerCase(),
|
|
833
837
|
{
|
|
834
838
|
...operation2,
|
|
835
|
-
path:
|
|
839
|
+
path: path38,
|
|
836
840
|
__pathless: false
|
|
837
841
|
}
|
|
838
842
|
])
|
|
839
843
|
);
|
|
840
844
|
}
|
|
841
|
-
return bindRoutePath(
|
|
845
|
+
return bindRoutePath(path38, definitionOrOperation);
|
|
842
846
|
}
|
|
843
847
|
function normalizeRouteSegment(segment) {
|
|
844
848
|
if (!segment) {
|
|
@@ -859,8 +863,8 @@ function normalizeRouteSegment(segment) {
|
|
|
859
863
|
function camelCaseRouteSegment(segment) {
|
|
860
864
|
return segment.replace(/-([a-zA-Z0-9])/g, (_match, value) => value.toUpperCase());
|
|
861
865
|
}
|
|
862
|
-
function getRouteClientSegments(
|
|
863
|
-
const segments =
|
|
866
|
+
function getRouteClientSegments(path38) {
|
|
867
|
+
const segments = path38.split("/").filter(Boolean);
|
|
864
868
|
if (segments.length === 0) {
|
|
865
869
|
return ["index"];
|
|
866
870
|
}
|
|
@@ -1239,11 +1243,11 @@ function resolveFarmServerHealthConfig(config) {
|
|
|
1239
1243
|
return Object.freeze({ enabled: true, livenessPath, readinessPath });
|
|
1240
1244
|
}
|
|
1241
1245
|
function normalizeHealthPath(value, optionName) {
|
|
1242
|
-
const
|
|
1243
|
-
if (!
|
|
1246
|
+
const path38 = value.trim();
|
|
1247
|
+
if (!path38.startsWith("/") || path38.includes("?") || path38.includes("#") || path38.includes("*")) {
|
|
1244
1248
|
throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
|
|
1245
1249
|
}
|
|
1246
|
-
return
|
|
1250
|
+
return path38.length > 1 ? path38.replace(/\/+$/, "") || "/" : path38;
|
|
1247
1251
|
}
|
|
1248
1252
|
function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
|
|
1249
1253
|
if (typeof value === "number") {
|
|
@@ -1584,9 +1588,9 @@ function getFarmIntegrationPluginOwner(plugin) {
|
|
|
1584
1588
|
const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
|
|
1585
1589
|
return value && typeof value === "object" ? value : void 0;
|
|
1586
1590
|
}
|
|
1587
|
-
function defineTypedIntegrationRoute(method,
|
|
1591
|
+
function defineTypedIntegrationRoute(method, path38, input) {
|
|
1588
1592
|
return {
|
|
1589
|
-
path:
|
|
1593
|
+
path: path38,
|
|
1590
1594
|
method,
|
|
1591
1595
|
middleware: input.middleware,
|
|
1592
1596
|
before: input.before,
|
|
@@ -1596,7 +1600,7 @@ function defineTypedIntegrationRoute(method, path37, input) {
|
|
|
1596
1600
|
input: normalizeIntegrationRouteInputSchemas(input),
|
|
1597
1601
|
handler: input.handler,
|
|
1598
1602
|
__operation: defineIntegrationAPIOperation({
|
|
1599
|
-
path:
|
|
1603
|
+
path: path38,
|
|
1600
1604
|
method,
|
|
1601
1605
|
bodyFormat: input.bodyFormat,
|
|
1602
1606
|
responseFormat: input.responseFormat,
|
|
@@ -1608,58 +1612,58 @@ function defineTypedIntegrationRoute(method, path37, input) {
|
|
|
1608
1612
|
}
|
|
1609
1613
|
function createIntegrationRouteFactory() {
|
|
1610
1614
|
return {
|
|
1611
|
-
get(
|
|
1615
|
+
get(path38, input) {
|
|
1612
1616
|
return defineTypedIntegrationRoute(
|
|
1613
1617
|
"GET",
|
|
1614
|
-
|
|
1618
|
+
path38,
|
|
1615
1619
|
input
|
|
1616
1620
|
);
|
|
1617
1621
|
},
|
|
1618
|
-
post(
|
|
1622
|
+
post(path38, input) {
|
|
1619
1623
|
return defineTypedIntegrationRoute(
|
|
1620
1624
|
"POST",
|
|
1621
|
-
|
|
1625
|
+
path38,
|
|
1622
1626
|
{
|
|
1623
1627
|
bodyFormat: "json",
|
|
1624
1628
|
...input
|
|
1625
1629
|
}
|
|
1626
1630
|
);
|
|
1627
1631
|
},
|
|
1628
|
-
query(
|
|
1629
|
-
return defineTypedIntegrationRoute("QUERY",
|
|
1632
|
+
query(path38, input) {
|
|
1633
|
+
return defineTypedIntegrationRoute("QUERY", path38, {
|
|
1630
1634
|
bodyFormat: "json",
|
|
1631
1635
|
...input
|
|
1632
1636
|
});
|
|
1633
1637
|
},
|
|
1634
|
-
put(
|
|
1638
|
+
put(path38, input) {
|
|
1635
1639
|
return defineTypedIntegrationRoute(
|
|
1636
1640
|
"PUT",
|
|
1637
|
-
|
|
1641
|
+
path38,
|
|
1638
1642
|
{
|
|
1639
1643
|
bodyFormat: "json",
|
|
1640
1644
|
...input
|
|
1641
1645
|
}
|
|
1642
1646
|
);
|
|
1643
1647
|
},
|
|
1644
|
-
patch(
|
|
1645
|
-
return defineTypedIntegrationRoute("PATCH",
|
|
1648
|
+
patch(path38, input) {
|
|
1649
|
+
return defineTypedIntegrationRoute("PATCH", path38, {
|
|
1646
1650
|
bodyFormat: "json",
|
|
1647
1651
|
...input
|
|
1648
1652
|
});
|
|
1649
1653
|
},
|
|
1650
|
-
delete(
|
|
1651
|
-
return defineTypedIntegrationRoute("DELETE",
|
|
1654
|
+
delete(path38, input) {
|
|
1655
|
+
return defineTypedIntegrationRoute("DELETE", path38, {
|
|
1652
1656
|
bodyFormat: "json",
|
|
1653
1657
|
...input
|
|
1654
1658
|
});
|
|
1655
1659
|
},
|
|
1656
|
-
options(
|
|
1657
|
-
return defineTypedIntegrationRoute("OPTIONS",
|
|
1660
|
+
options(path38, input) {
|
|
1661
|
+
return defineTypedIntegrationRoute("OPTIONS", path38, input);
|
|
1658
1662
|
},
|
|
1659
|
-
head(
|
|
1663
|
+
head(path38, input) {
|
|
1660
1664
|
return defineTypedIntegrationRoute(
|
|
1661
1665
|
"HEAD",
|
|
1662
|
-
|
|
1666
|
+
path38,
|
|
1663
1667
|
input
|
|
1664
1668
|
);
|
|
1665
1669
|
}
|
|
@@ -2006,8 +2010,8 @@ async function parseIntegrationConfigSchema(integration, schema, value) {
|
|
|
2006
2010
|
function createIntegrationConfigValidationError(integration, error) {
|
|
2007
2011
|
const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
|
|
2008
2012
|
const normalizedPath = normalizeIntegrationValidationPath(issue.path);
|
|
2009
|
-
const
|
|
2010
|
-
return `${
|
|
2013
|
+
const path38 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
|
|
2014
|
+
return `${path38}${issue.message || "Invalid config"}`;
|
|
2011
2015
|
}).join("; ") : error.message || "Invalid config";
|
|
2012
2016
|
return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
|
|
2013
2017
|
}
|
|
@@ -2716,8 +2720,8 @@ function normalizeIntegrationValidationIssues(source, error) {
|
|
|
2716
2720
|
}
|
|
2717
2721
|
];
|
|
2718
2722
|
}
|
|
2719
|
-
function normalizeIntegrationValidationPath(
|
|
2720
|
-
return (
|
|
2723
|
+
function normalizeIntegrationValidationPath(path38) {
|
|
2724
|
+
return (path38 || []).map((segment) => {
|
|
2721
2725
|
const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
|
|
2722
2726
|
return typeof key === "symbol" ? key.description || key.toString() : key;
|
|
2723
2727
|
});
|
|
@@ -3992,20 +3996,20 @@ async function prepareFarmWorkflowsForNitro(config) {
|
|
|
3992
3996
|
const root = config.root || process.cwd();
|
|
3993
3997
|
const distDir = config.distDir || ".farm";
|
|
3994
3998
|
const fs13 = await import("fs/promises");
|
|
3995
|
-
const
|
|
3996
|
-
const generatedDir =
|
|
3999
|
+
const path38 = await import("path");
|
|
4000
|
+
const generatedDir = path38.join(root, distDir, ".nitro", "farm-workflows");
|
|
3997
4001
|
await fs13.mkdir(generatedDir, { recursive: true });
|
|
3998
4002
|
const tasks = {};
|
|
3999
4003
|
const scheduledTasks = createScheduledTasks(workflows);
|
|
4000
4004
|
for (const workflow of workflows) {
|
|
4001
|
-
const wrapperPath =
|
|
4005
|
+
const wrapperPath = path38.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
|
|
4002
4006
|
await fs13.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
|
|
4003
4007
|
tasks[workflow.id] = {
|
|
4004
4008
|
handler: wrapperPath,
|
|
4005
4009
|
description: workflow.description || `Farm workflow ${workflow.id}`
|
|
4006
4010
|
};
|
|
4007
4011
|
}
|
|
4008
|
-
const handlerPath =
|
|
4012
|
+
const handlerPath = path38.join(generatedDir, "http-handler.mjs");
|
|
4009
4013
|
await fs13.writeFile(
|
|
4010
4014
|
handlerPath,
|
|
4011
4015
|
createNitroWorkflowHTTPHandler(
|
|
@@ -4015,7 +4019,7 @@ async function prepareFarmWorkflowsForNitro(config) {
|
|
|
4015
4019
|
),
|
|
4016
4020
|
"utf8"
|
|
4017
4021
|
);
|
|
4018
|
-
const manifestPath =
|
|
4022
|
+
const manifestPath = path38.join(generatedDir, "manifest.json");
|
|
4019
4023
|
await fs13.writeFile(
|
|
4020
4024
|
manifestPath,
|
|
4021
4025
|
JSON.stringify(
|
|
@@ -4098,10 +4102,10 @@ function resolveWorkflowDefinition(module2) {
|
|
|
4098
4102
|
}
|
|
4099
4103
|
async function findWorkflowFiles(root, dirs) {
|
|
4100
4104
|
const fs13 = await import("fs/promises");
|
|
4101
|
-
const
|
|
4105
|
+
const path38 = await import("path");
|
|
4102
4106
|
const files = [];
|
|
4103
4107
|
for (const dir of dirs) {
|
|
4104
|
-
const absoluteDir =
|
|
4108
|
+
const absoluteDir = path38.isAbsolute(dir) ? dir : path38.join(root, dir);
|
|
4105
4109
|
if (!await pathExists(absoluteDir)) continue;
|
|
4106
4110
|
await walkWorkflowDir(absoluteDir, files);
|
|
4107
4111
|
}
|
|
@@ -4109,10 +4113,10 @@ async function findWorkflowFiles(root, dirs) {
|
|
|
4109
4113
|
}
|
|
4110
4114
|
async function walkWorkflowDir(dir, files) {
|
|
4111
4115
|
const fs13 = await import("fs/promises");
|
|
4112
|
-
const
|
|
4116
|
+
const path38 = await import("path");
|
|
4113
4117
|
const entries = await fs13.readdir(dir, { withFileTypes: true });
|
|
4114
4118
|
for (const entry of entries) {
|
|
4115
|
-
const filePath =
|
|
4119
|
+
const filePath = path38.join(dir, entry.name);
|
|
4116
4120
|
if (entry.isDirectory()) {
|
|
4117
4121
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
4118
4122
|
await walkWorkflowDir(filePath, files);
|
|
@@ -4132,12 +4136,12 @@ function isWorkflowFile(fileName) {
|
|
|
4132
4136
|
}
|
|
4133
4137
|
async function loadWorkflowModule(filePath, root) {
|
|
4134
4138
|
const fs13 = await import("fs/promises");
|
|
4135
|
-
const
|
|
4139
|
+
const path38 = await import("path");
|
|
4136
4140
|
const { pathToFileURL: pathToFileURL9 } = await import("url");
|
|
4137
4141
|
const { build: build3 } = await import("esbuild");
|
|
4138
|
-
const outDir =
|
|
4142
|
+
const outDir = path38.join(root, ".farm", ".workflow-loader");
|
|
4139
4143
|
await fs13.mkdir(outDir, { recursive: true });
|
|
4140
|
-
const outfile =
|
|
4144
|
+
const outfile = path38.join(
|
|
4141
4145
|
outDir,
|
|
4142
4146
|
`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
|
|
4143
4147
|
);
|
|
@@ -4432,9 +4436,9 @@ async function prepareFarmCronForNitro(config) {
|
|
|
4432
4436
|
const root = config.root || process.cwd();
|
|
4433
4437
|
const distDir = config.distDir || ".farm";
|
|
4434
4438
|
const fs13 = await import("fs/promises");
|
|
4435
|
-
const
|
|
4436
|
-
const manifestPath =
|
|
4437
|
-
const generatedDir =
|
|
4439
|
+
const path38 = await import("path");
|
|
4440
|
+
const manifestPath = path38.join(root, distDir, FARM_CRON_MANIFEST);
|
|
4441
|
+
const generatedDir = path38.join(root, distDir, ".nitro", "farm-cron");
|
|
4438
4442
|
if (!cron.enabled) {
|
|
4439
4443
|
await Promise.all([
|
|
4440
4444
|
fs13.rm(manifestPath, { force: true }),
|
|
@@ -4451,7 +4455,7 @@ async function prepareFarmCronForNitro(config) {
|
|
|
4451
4455
|
const tasks = {};
|
|
4452
4456
|
for (const job of cron.jobs) {
|
|
4453
4457
|
const taskName = getFarmCronTaskName(job.name);
|
|
4454
|
-
const wrapperPath =
|
|
4458
|
+
const wrapperPath = path38.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
|
|
4455
4459
|
await fs13.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
|
|
4456
4460
|
tasks[taskName] = {
|
|
4457
4461
|
handler: wrapperPath,
|
|
@@ -4459,7 +4463,7 @@ async function prepareFarmCronForNitro(config) {
|
|
|
4459
4463
|
};
|
|
4460
4464
|
}
|
|
4461
4465
|
const manifest = createFarmCronManifest(cron);
|
|
4462
|
-
await fs13.mkdir(
|
|
4466
|
+
await fs13.mkdir(path38.dirname(manifestPath), { recursive: true });
|
|
4463
4467
|
await fs13.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
4464
4468
|
`, "utf8");
|
|
4465
4469
|
return {
|
|
@@ -4561,7 +4565,7 @@ function normalizeCronJob(name2, job) {
|
|
|
4561
4565
|
if (!job || typeof job !== "object" || Array.isArray(job)) {
|
|
4562
4566
|
throw new TypeError(`Farm cron ${JSON.stringify(name2)} must be a configuration object.`);
|
|
4563
4567
|
}
|
|
4564
|
-
const
|
|
4568
|
+
const path38 = normalizeCronPath(name2, job.path);
|
|
4565
4569
|
const rawSchedule = Array.isArray(job.schedule) ? job.schedule : [job.schedule];
|
|
4566
4570
|
const schedule = [...new Set(rawSchedule.map((value) => normalizeCronExpression(name2, value)))];
|
|
4567
4571
|
if (schedule.length === 0) {
|
|
@@ -4570,7 +4574,7 @@ function normalizeCronJob(name2, job) {
|
|
|
4570
4574
|
return {
|
|
4571
4575
|
name: name2,
|
|
4572
4576
|
schedule,
|
|
4573
|
-
path:
|
|
4577
|
+
path: path38,
|
|
4574
4578
|
description: job.description?.trim() || void 0
|
|
4575
4579
|
};
|
|
4576
4580
|
}
|
|
@@ -4578,13 +4582,13 @@ function normalizeCronPath(name2, value) {
|
|
|
4578
4582
|
if (typeof value !== "string" || !value.trim().startsWith("/")) {
|
|
4579
4583
|
throw new TypeError(`Farm cron ${JSON.stringify(name2)} path must start with "/".`);
|
|
4580
4584
|
}
|
|
4581
|
-
const
|
|
4582
|
-
if (
|
|
4585
|
+
const path38 = value.trim();
|
|
4586
|
+
if (path38.startsWith("//") || path38.includes("?") || path38.includes("#")) {
|
|
4583
4587
|
throw new TypeError(
|
|
4584
4588
|
`Farm cron ${JSON.stringify(name2)} path must be an application pathname without a host, query, or hash.`
|
|
4585
4589
|
);
|
|
4586
4590
|
}
|
|
4587
|
-
return
|
|
4591
|
+
return path38.length > 1 ? path38.replace(/\/+$/, "") : path38;
|
|
4588
4592
|
}
|
|
4589
4593
|
function normalizeCronExpression(name2, value) {
|
|
4590
4594
|
if (typeof value !== "string") {
|
|
@@ -6096,7 +6100,7 @@ var init_server_action_security = __esm({
|
|
|
6096
6100
|
|
|
6097
6101
|
// src/image-config.ts
|
|
6098
6102
|
function resolveFarmImageConfig(config) {
|
|
6099
|
-
const
|
|
6103
|
+
const path38 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
|
|
6100
6104
|
const deviceSizes = normalizeIntegerList(
|
|
6101
6105
|
config?.deviceSizes ?? DEFAULT_FARM_IMAGE_DEVICE_SIZES,
|
|
6102
6106
|
"images.deviceSizes"
|
|
@@ -6124,7 +6128,7 @@ function resolveFarmImageConfig(config) {
|
|
|
6124
6128
|
);
|
|
6125
6129
|
return Object.freeze({
|
|
6126
6130
|
provider: config?.provider ?? "auto",
|
|
6127
|
-
path:
|
|
6131
|
+
path: path38,
|
|
6128
6132
|
domains: Object.freeze([
|
|
6129
6133
|
...new Set(
|
|
6130
6134
|
(config?.domains ?? []).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
|
|
@@ -6163,11 +6167,11 @@ function getPublicFarmImageConfig(config) {
|
|
|
6163
6167
|
};
|
|
6164
6168
|
}
|
|
6165
6169
|
function normalizeImagePath(value) {
|
|
6166
|
-
const
|
|
6167
|
-
if (!
|
|
6170
|
+
const path38 = value.trim().replace(/\/+$/, "") || "/";
|
|
6171
|
+
if (!path38.startsWith("/") || path38.includes("?") || path38.includes("#")) {
|
|
6168
6172
|
throw new TypeError("images.path must be an absolute pathname without a query or hash");
|
|
6169
6173
|
}
|
|
6170
|
-
return
|
|
6174
|
+
return path38;
|
|
6171
6175
|
}
|
|
6172
6176
|
function normalizeIntegerList(values, name2, max) {
|
|
6173
6177
|
if (values.length === 0) {
|
|
@@ -8283,7 +8287,7 @@ function getProgrammaticRouteSearchClientOptions2(search) {
|
|
|
8283
8287
|
if (search.temporary?.length) options.temporary = [...search.temporary];
|
|
8284
8288
|
return Object.keys(options).length > 0 ? options : void 0;
|
|
8285
8289
|
}
|
|
8286
|
-
function resolveProgrammaticRouteSearch(searchConfig, rawSearch,
|
|
8290
|
+
function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path38, routePath) {
|
|
8287
8291
|
const schema = getProgrammaticRouteSearchSchema(searchConfig);
|
|
8288
8292
|
const search = parseProgrammaticSchema(schema, rawSearch, "search", routePath);
|
|
8289
8293
|
const options = getProgrammaticRouteSearchOptions(searchConfig);
|
|
@@ -8292,7 +8296,7 @@ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path37, routePa
|
|
|
8292
8296
|
schema,
|
|
8293
8297
|
rawSearch,
|
|
8294
8298
|
parsedSearch: search,
|
|
8295
|
-
path:
|
|
8299
|
+
path: path38
|
|
8296
8300
|
});
|
|
8297
8301
|
return { search, canonicalPath };
|
|
8298
8302
|
}
|
|
@@ -8371,8 +8375,8 @@ function normalizeComparableValue(value) {
|
|
|
8371
8375
|
}
|
|
8372
8376
|
return value;
|
|
8373
8377
|
}
|
|
8374
|
-
function createRoute(
|
|
8375
|
-
return routesBuilder.page(
|
|
8378
|
+
function createRoute(path38, options) {
|
|
8379
|
+
return routesBuilder.page(path38, options);
|
|
8376
8380
|
}
|
|
8377
8381
|
function isProgrammaticRoutesFileName2(fileName) {
|
|
8378
8382
|
const normalized = fileName.replace(/\\/g, "/");
|
|
@@ -8462,7 +8466,7 @@ function createRouteModuleFromProgrammaticPage(route2, rendererRuntime) {
|
|
|
8462
8466
|
mod.__farmRouteData = route2.data;
|
|
8463
8467
|
mod.__farmRouteParsesProps = true;
|
|
8464
8468
|
mod.__farmResolveRouteProps = (props) => resolveProgrammaticRouteProps(route2, props);
|
|
8465
|
-
mod.__farmResolveRouteCanonicalPath = (rawSearch,
|
|
8469
|
+
mod.__farmResolveRouteCanonicalPath = (rawSearch, path38) => resolveProgrammaticRouteSearch(route2.search, rawSearch, path38, route2.path).canonicalPath;
|
|
8466
8470
|
}
|
|
8467
8471
|
if (route2.pending || route2.error || route2.notFound) {
|
|
8468
8472
|
mod.__farmRouteComponents = {
|
|
@@ -8898,25 +8902,25 @@ var init_routes = __esm({
|
|
|
8898
8902
|
];
|
|
8899
8903
|
__name(defineRoutes, "defineRoutes");
|
|
8900
8904
|
routesBuilder = {
|
|
8901
|
-
page(
|
|
8905
|
+
page(path38, options) {
|
|
8902
8906
|
return normalizeProgrammaticRoute({
|
|
8903
8907
|
kind: "page",
|
|
8904
|
-
path:
|
|
8908
|
+
path: path38,
|
|
8905
8909
|
...options
|
|
8906
8910
|
});
|
|
8907
8911
|
},
|
|
8908
|
-
layout(
|
|
8912
|
+
layout(path38, options) {
|
|
8909
8913
|
return normalizeProgrammaticRoute({
|
|
8910
8914
|
kind: "layout",
|
|
8911
|
-
path:
|
|
8915
|
+
path: path38,
|
|
8912
8916
|
...options
|
|
8913
8917
|
});
|
|
8914
8918
|
},
|
|
8915
|
-
api(
|
|
8919
|
+
api(path38, options) {
|
|
8916
8920
|
const { render, runtime, regions, maxDuration, ...methods } = options;
|
|
8917
8921
|
return normalizeProgrammaticRoute({
|
|
8918
8922
|
kind: "api",
|
|
8919
|
-
path:
|
|
8923
|
+
path: path38,
|
|
8920
8924
|
render,
|
|
8921
8925
|
runtime,
|
|
8922
8926
|
regions,
|
|
@@ -12054,8 +12058,8 @@ function createFarmDeploymentMismatchError(response, clientDeploymentId) {
|
|
|
12054
12058
|
getFarmResponseDeploymentId(response) || "unknown"
|
|
12055
12059
|
);
|
|
12056
12060
|
}
|
|
12057
|
-
function createFarmDeploymentCookie(deploymentId,
|
|
12058
|
-
const normalizedPath =
|
|
12061
|
+
function createFarmDeploymentCookie(deploymentId, path38 = "/", secure = false) {
|
|
12062
|
+
const normalizedPath = path38.startsWith("/") ? path38 : `/${path38}`;
|
|
12059
12063
|
return [
|
|
12060
12064
|
`${FARM_DEPLOYMENT_COOKIE}=${encodeURIComponent(deploymentId)}`,
|
|
12061
12065
|
`Path=${normalizedPath}`,
|
|
@@ -14912,7 +14916,7 @@ var init_server3 = __esm({
|
|
|
14912
14916
|
var version;
|
|
14913
14917
|
var init_package = __esm({
|
|
14914
14918
|
"package.json"() {
|
|
14915
|
-
version = "0.1.0-beta.
|
|
14919
|
+
version = "0.1.0-beta.34";
|
|
14916
14920
|
}
|
|
14917
14921
|
});
|
|
14918
14922
|
|
|
@@ -17302,14 +17306,14 @@ function normalizeFarmAPIConfig(config) {
|
|
|
17302
17306
|
};
|
|
17303
17307
|
}
|
|
17304
17308
|
function normalizeFarmAPIBasePath(value) {
|
|
17305
|
-
const
|
|
17306
|
-
if (!
|
|
17309
|
+
const path38 = value.trim();
|
|
17310
|
+
if (!path38) {
|
|
17307
17311
|
throw new Error("Farm api.basePath cannot be empty.");
|
|
17308
17312
|
}
|
|
17309
|
-
if (
|
|
17313
|
+
if (path38.includes("?") || path38.includes("#")) {
|
|
17310
17314
|
throw new Error("Farm api.basePath cannot contain a query string or hash.");
|
|
17311
17315
|
}
|
|
17312
|
-
const normalized = `/${
|
|
17316
|
+
const normalized = `/${path38.replace(/^\/+|\/+$/g, "")}`;
|
|
17313
17317
|
return normalized === "/" ? "/" : normalized;
|
|
17314
17318
|
}
|
|
17315
17319
|
function getFarmAPIBaseURL() {
|
|
@@ -18228,15 +18232,15 @@ function isEndpointFailure(value) {
|
|
|
18228
18232
|
return value instanceof EndpointFailure;
|
|
18229
18233
|
}
|
|
18230
18234
|
function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
|
|
18231
|
-
let
|
|
18235
|
+
let path38;
|
|
18232
18236
|
let options;
|
|
18233
18237
|
let handler;
|
|
18234
18238
|
if (typeof pathOrOptions === "string") {
|
|
18235
|
-
|
|
18239
|
+
path38 = pathOrOptions;
|
|
18236
18240
|
options = optionsOrHandler;
|
|
18237
18241
|
handler = maybeHandler;
|
|
18238
18242
|
} else {
|
|
18239
|
-
|
|
18243
|
+
path38 = "";
|
|
18240
18244
|
options = pathOrOptions;
|
|
18241
18245
|
handler = optionsOrHandler;
|
|
18242
18246
|
}
|
|
@@ -18263,13 +18267,13 @@ function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
|
|
|
18263
18267
|
...betterCallOptions
|
|
18264
18268
|
} = options;
|
|
18265
18269
|
const endpoint2 = (0, import_better_call.createEndpoint)(
|
|
18266
|
-
|
|
18270
|
+
path38 || "/__farm_auto_path__",
|
|
18267
18271
|
betterCallOptions,
|
|
18268
18272
|
wrappedHandler
|
|
18269
18273
|
);
|
|
18270
|
-
endpoint2.__path =
|
|
18274
|
+
endpoint2.__path = path38 || void 0;
|
|
18271
18275
|
endpoint2.__method = options.method || "GET";
|
|
18272
|
-
endpoint2.__autoPath = !
|
|
18276
|
+
endpoint2.__autoPath = !path38;
|
|
18273
18277
|
endpoint2.__handler = wrappedHandler;
|
|
18274
18278
|
endpoint2.__farmInvoke = (ctx) => runEndpointMiddleware(middleware2, ctx, handler, error, options.invalidates);
|
|
18275
18279
|
endpoint2.__middleware = middleware2;
|
|
@@ -20013,11 +20017,11 @@ var init_type_generator = __esm({
|
|
|
20013
20017
|
routeGroups.get(key).push(route2);
|
|
20014
20018
|
}
|
|
20015
20019
|
const nestedStructure = {};
|
|
20016
|
-
for (const [
|
|
20020
|
+
for (const [path38, routeList] of routeGroups) {
|
|
20017
20021
|
const route2 = routeList[0];
|
|
20018
20022
|
const importPath = this.getRouteImportPath(route2, options.outFile);
|
|
20019
20023
|
const routeName = this.pathToRouteName(route2.path);
|
|
20020
|
-
const cleanPath =
|
|
20024
|
+
const cleanPath = path38 === "/api" ? "" : path38.replace(/^\/api\//, "");
|
|
20021
20025
|
const parts = cleanPath ? cleanPath.split("/") : [];
|
|
20022
20026
|
const allMethods = routeList.flatMap((r) => r.methods);
|
|
20023
20027
|
for (const method of allMethods) {
|
|
@@ -20076,8 +20080,8 @@ ${typeExports}
|
|
|
20076
20080
|
const relativeImport = (0, import_path7.relative)((0, import_path7.dirname)(outFile), route2.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
20077
20081
|
return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
|
|
20078
20082
|
}
|
|
20079
|
-
pathToRouteName(
|
|
20080
|
-
return (
|
|
20083
|
+
pathToRouteName(path38) {
|
|
20084
|
+
return (path38 === "/api" ? "root" : path38.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
|
|
20081
20085
|
}
|
|
20082
20086
|
structureToTypeString(obj, indent) {
|
|
20083
20087
|
const spaces = " ".repeat(indent);
|
|
@@ -20097,15 +20101,15 @@ ${typeExports}
|
|
|
20097
20101
|
toTypePropertyKey(key) {
|
|
20098
20102
|
return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
|
|
20099
20103
|
}
|
|
20100
|
-
getBaseExportName(
|
|
20101
|
-
const cleanPath =
|
|
20104
|
+
getBaseExportName(path38) {
|
|
20105
|
+
const cleanPath = path38.replace(/^\/api\//, "");
|
|
20102
20106
|
if (cleanPath === "") {
|
|
20103
20107
|
return "api";
|
|
20104
20108
|
}
|
|
20105
20109
|
return cleanPath;
|
|
20106
20110
|
}
|
|
20107
|
-
getExportName(
|
|
20108
|
-
const cleanPath =
|
|
20111
|
+
getExportName(path38, method) {
|
|
20112
|
+
const cleanPath = path38.replace(/^\/api\//, "");
|
|
20109
20113
|
if (cleanPath === "") {
|
|
20110
20114
|
return method.toLowerCase();
|
|
20111
20115
|
}
|
|
@@ -24378,7 +24382,8 @@ function resolveDeployOutputPath(root, outputDir) {
|
|
|
24378
24382
|
function resolveDeployConfig(config, overrides = {}) {
|
|
24379
24383
|
const deploy = config.deploy || {};
|
|
24380
24384
|
const distDir = config.distDir || ".farm";
|
|
24381
|
-
const
|
|
24385
|
+
const overrideTarget = normalizeDeployTarget(overrides.target);
|
|
24386
|
+
const target = overrideTarget ? overrideTarget : overrides.preset ? getDeployTargetForPreset(overrides.preset) : normalizeDeployTarget(deploy.target);
|
|
24382
24387
|
const preset = overrides.preset || deploy.preset || config.preset || getPresetForDeployTarget(target) || "node-server";
|
|
24383
24388
|
const resolvedTarget = target || getDeployTargetForPreset(preset);
|
|
24384
24389
|
const platformOutput = resolvedTarget === "vercel" ? deploy.vercel?.outputDirectory : resolvedTarget === "cloudflare" ? deploy.cloudflare?.outputDir : resolvedTarget === "netlify" ? deploy.netlify?.outputDir : void 0;
|
|
@@ -24410,6 +24415,14 @@ function normalizeDocsContentDir(value) {
|
|
|
24410
24415
|
const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
24411
24416
|
return normalized || void 0;
|
|
24412
24417
|
}
|
|
24418
|
+
async function inferDocsContentDir(root, srcDir, entry) {
|
|
24419
|
+
const { existsSync: existsSync20 } = await import("fs");
|
|
24420
|
+
const contentDir = import_path9.default.resolve(root, srcDir, "app", entry);
|
|
24421
|
+
if (!existsSync20(contentDir)) return void 0;
|
|
24422
|
+
const relativeContentDir = import_path9.default.relative(root, contentDir);
|
|
24423
|
+
if (relativeContentDir.startsWith("..") || import_path9.default.isAbsolute(relativeContentDir)) return void 0;
|
|
24424
|
+
return normalizeDocsContentDir(relativeContentDir);
|
|
24425
|
+
}
|
|
24413
24426
|
function isRecord3(value) {
|
|
24414
24427
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
24415
24428
|
}
|
|
@@ -24561,7 +24574,10 @@ async function resolveDocsConfig(userDocs, options = {}) {
|
|
|
24561
24574
|
configuredDocsPath || explicitRoute || (configuredEntry ? `/${configuredEntry}` : void 0)
|
|
24562
24575
|
);
|
|
24563
24576
|
const docsEntry = explicitRoute && explicitRoute.startsWith("/") ? docsRouteToEntry(explicitRoute) : docsRouteToEntry(configuredEntry || entryRoute);
|
|
24564
|
-
const
|
|
24577
|
+
const configuredContentDir = normalizeDocsContentDir(
|
|
24578
|
+
docsOptions.contentDir || mergedDocsConfig.contentDir
|
|
24579
|
+
);
|
|
24580
|
+
const contentDir = configuredContentDir || await inferDocsContentDir(root, options.srcDir || "src", docsEntry);
|
|
24565
24581
|
return {
|
|
24566
24582
|
enabled: true,
|
|
24567
24583
|
entry: entryRoute,
|
|
@@ -24784,6 +24800,7 @@ var init_config4 = __esm({
|
|
|
24784
24800
|
__name(normalizeDocsRoute, "normalizeDocsRoute");
|
|
24785
24801
|
__name(docsRouteToEntry, "docsRouteToEntry");
|
|
24786
24802
|
__name(normalizeDocsContentDir, "normalizeDocsContentDir");
|
|
24803
|
+
__name(inferDocsContentDir, "inferDocsContentDir");
|
|
24787
24804
|
__name(isRecord3, "isRecord");
|
|
24788
24805
|
__name(cloneSerializable, "cloneSerializable");
|
|
24789
24806
|
__name(sanitizeDocsConfig, "sanitizeDocsConfig");
|
|
@@ -25561,8 +25578,8 @@ var init_generator = __esm({
|
|
|
25561
25578
|
}
|
|
25562
25579
|
routeGroups.get(key).push(route2);
|
|
25563
25580
|
}
|
|
25564
|
-
for (const [
|
|
25565
|
-
const openAPIPath = this.convertToOpenAPIPath(
|
|
25581
|
+
for (const [path38, routeList] of routeGroups) {
|
|
25582
|
+
const openAPIPath = this.convertToOpenAPIPath(path38);
|
|
25566
25583
|
spec.paths[openAPIPath] = {};
|
|
25567
25584
|
for (const route2 of routeList) {
|
|
25568
25585
|
for (const method of route2.methods) {
|
|
@@ -25582,8 +25599,8 @@ var init_generator = __esm({
|
|
|
25582
25599
|
/**
|
|
25583
25600
|
* Convert Farm.js API path to OpenAPI path format
|
|
25584
25601
|
*/
|
|
25585
|
-
convertToOpenAPIPath(
|
|
25586
|
-
return
|
|
25602
|
+
convertToOpenAPIPath(path38) {
|
|
25603
|
+
return path38.replace(/^\/api/, "");
|
|
25587
25604
|
}
|
|
25588
25605
|
/**
|
|
25589
25606
|
* Extract request body schema from endpoint
|
|
@@ -25745,8 +25762,8 @@ var init_generator = __esm({
|
|
|
25745
25762
|
/**
|
|
25746
25763
|
* Generate operation summary
|
|
25747
25764
|
*/
|
|
25748
|
-
generateSummary(
|
|
25749
|
-
const cleanPath =
|
|
25765
|
+
generateSummary(path38, method) {
|
|
25766
|
+
const cleanPath = path38.replace(/^\/api\//, "");
|
|
25750
25767
|
const pathParts = cleanPath.split("/");
|
|
25751
25768
|
const lastPart = pathParts[pathParts.length - 1];
|
|
25752
25769
|
const action = method === "GET" ? "Get" : method === "QUERY" ? "Query" : method === "POST" ? "Create" : method === "PUT" ? "Update" : method === "DELETE" ? "Delete" : method === "PATCH" ? "Update" : method;
|
|
@@ -25755,22 +25772,22 @@ var init_generator = __esm({
|
|
|
25755
25772
|
/**
|
|
25756
25773
|
* Generate operation description
|
|
25757
25774
|
*/
|
|
25758
|
-
generateDescription(
|
|
25759
|
-
const cleanPath =
|
|
25775
|
+
generateDescription(path38, method) {
|
|
25776
|
+
const cleanPath = path38.replace(/^\/api\//, "");
|
|
25760
25777
|
return `${method} ${cleanPath} endpoint`;
|
|
25761
25778
|
}
|
|
25762
25779
|
/**
|
|
25763
25780
|
* Generate operation ID
|
|
25764
25781
|
*/
|
|
25765
|
-
generateOperationId(
|
|
25766
|
-
const cleanPath =
|
|
25782
|
+
generateOperationId(path38, method) {
|
|
25783
|
+
const cleanPath = path38.replace(/^\/api\//, "").replace(/\//g, "_");
|
|
25767
25784
|
return `${method.toLowerCase()}_${cleanPath}`;
|
|
25768
25785
|
}
|
|
25769
25786
|
/**
|
|
25770
25787
|
* Generate tags for grouping operations
|
|
25771
25788
|
*/
|
|
25772
|
-
generateTags(
|
|
25773
|
-
const cleanPath =
|
|
25789
|
+
generateTags(path38) {
|
|
25790
|
+
const cleanPath = path38.replace(/^\/api\//, "");
|
|
25774
25791
|
const pathParts = cleanPath.split("/");
|
|
25775
25792
|
if (pathParts.length > 1) {
|
|
25776
25793
|
return [pathParts[0]];
|
|
@@ -25783,8 +25800,8 @@ var init_generator = __esm({
|
|
|
25783
25800
|
async generateSpecFile(routes, outputPath) {
|
|
25784
25801
|
const spec = await this.generateSpec(routes);
|
|
25785
25802
|
const fs13 = require("fs");
|
|
25786
|
-
const
|
|
25787
|
-
const dir =
|
|
25803
|
+
const path38 = require("path");
|
|
25804
|
+
const dir = path38.dirname(outputPath);
|
|
25788
25805
|
if (!fs13.existsSync(dir)) {
|
|
25789
25806
|
fs13.mkdirSync(dir, { recursive: true });
|
|
25790
25807
|
}
|
|
@@ -32826,13 +32843,13 @@ async function createNitroConfig(config, routeManager, apiRouteManager, serverRe
|
|
|
32826
32843
|
const root = config.root || process.cwd();
|
|
32827
32844
|
const srcDir = config.srcDir || "src";
|
|
32828
32845
|
const distDir = ".farm";
|
|
32829
|
-
const nitroBuildDir =
|
|
32830
|
-
const outputDir =
|
|
32831
|
-
const serverDir =
|
|
32846
|
+
const nitroBuildDir = import_path14.default.join(root, distDir, ".nitro");
|
|
32847
|
+
const outputDir = import_path14.default.join(root, distDir, ".output");
|
|
32848
|
+
const serverDir = import_path14.default.join(nitroBuildDir, "server");
|
|
32832
32849
|
const { mkdir: mkdir2, writeFile } = await import("fs/promises");
|
|
32833
32850
|
await mkdir2(serverDir, { recursive: true });
|
|
32834
|
-
await mkdir2(
|
|
32835
|
-
await mkdir2(
|
|
32851
|
+
await mkdir2(import_path14.default.join(serverDir, "api"), { recursive: true });
|
|
32852
|
+
await mkdir2(import_path14.default.join(serverDir, "routes"), { recursive: true });
|
|
32836
32853
|
const farmWorkflows = await prepareFarmWorkflowsForNitro({
|
|
32837
32854
|
...config,
|
|
32838
32855
|
distDir
|
|
@@ -32843,13 +32860,13 @@ async function createNitroConfig(config, routeManager, apiRouteManager, serverRe
|
|
|
32843
32860
|
});
|
|
32844
32861
|
const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
|
|
32845
32862
|
const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
|
|
32846
|
-
const registryFile =
|
|
32863
|
+
const registryFile = import_path14.default.join(serverDir, "farm-registry.ts");
|
|
32847
32864
|
const routePaths = {};
|
|
32848
32865
|
for (const [pattern, entry] of routeManager.getRoutes()) {
|
|
32849
32866
|
const bundledPath = entry.modulePath.replace(/.*\/src\/app\//, "").replace(/\.(tsx?|jsx?)$/, ".js");
|
|
32850
32867
|
routePaths[pattern] = bundledPath;
|
|
32851
32868
|
}
|
|
32852
|
-
const clientManifestPath =
|
|
32869
|
+
const clientManifestPath = import_path14.default.join(root, distDir, "client", "farm-client-manifest.json");
|
|
32853
32870
|
await writeFile(
|
|
32854
32871
|
registryFile,
|
|
32855
32872
|
`
|
|
@@ -32873,8 +32890,8 @@ export const farmRegistry: {
|
|
|
32873
32890
|
`,
|
|
32874
32891
|
"utf-8"
|
|
32875
32892
|
);
|
|
32876
|
-
const apiHandlerFile =
|
|
32877
|
-
await mkdir2(
|
|
32893
|
+
const apiHandlerFile = import_path14.default.join(serverDir, "api", "[...].ts");
|
|
32894
|
+
await mkdir2(import_path14.default.dirname(apiHandlerFile), { recursive: true });
|
|
32878
32895
|
await writeFile(
|
|
32879
32896
|
apiHandlerFile,
|
|
32880
32897
|
`
|
|
@@ -33018,8 +33035,8 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
33018
33035
|
`,
|
|
33019
33036
|
"utf-8"
|
|
33020
33037
|
);
|
|
33021
|
-
const ssrHandlerFile =
|
|
33022
|
-
await mkdir2(
|
|
33038
|
+
const ssrHandlerFile = import_path14.default.join(serverDir, "routes", "[...].ts");
|
|
33039
|
+
await mkdir2(import_path14.default.dirname(ssrHandlerFile), { recursive: true });
|
|
33023
33040
|
await writeFile(
|
|
33024
33041
|
ssrHandlerFile,
|
|
33025
33042
|
`
|
|
@@ -33386,16 +33403,16 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
33386
33403
|
// from creating its own .output directory inside .nitro
|
|
33387
33404
|
dir: outputDir,
|
|
33388
33405
|
// .farm/.output
|
|
33389
|
-
serverDir:
|
|
33406
|
+
serverDir: import_path14.default.join(outputDir, "server"),
|
|
33390
33407
|
// .farm/.output/server
|
|
33391
|
-
publicDir:
|
|
33408
|
+
publicDir: import_path14.default.join(outputDir, "public")
|
|
33392
33409
|
// .farm/.output/public
|
|
33393
33410
|
},
|
|
33394
33411
|
// Use Nitro hooks to populate the runtime registry
|
|
33395
33412
|
// This allows us to pass complex objects (route managers, renderers) at runtime
|
|
33396
33413
|
hooks: {
|
|
33397
33414
|
"build:before": /* @__PURE__ */ __name(async (nitro) => {
|
|
33398
|
-
const registryPath =
|
|
33415
|
+
const registryPath = import_path14.default.join(serverDir, "farm-registry.ts");
|
|
33399
33416
|
const { farmRegistry } = await import(
|
|
33400
33417
|
/* @vite-ignore */
|
|
33401
33418
|
registryPath
|
|
@@ -33407,7 +33424,7 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
33407
33424
|
}
|
|
33408
33425
|
farmRegistry.routePaths = routePaths2;
|
|
33409
33426
|
try {
|
|
33410
|
-
const clientManifestPath2 =
|
|
33427
|
+
const clientManifestPath2 = import_path14.default.join(
|
|
33411
33428
|
root,
|
|
33412
33429
|
distDir,
|
|
33413
33430
|
"client",
|
|
@@ -33447,12 +33464,12 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
33447
33464
|
publicAssets: [
|
|
33448
33465
|
{
|
|
33449
33466
|
baseURL: "/",
|
|
33450
|
-
dir:
|
|
33467
|
+
dir: import_path14.default.join(root, "public")
|
|
33451
33468
|
},
|
|
33452
33469
|
// Include client build assets
|
|
33453
33470
|
{
|
|
33454
33471
|
baseURL: "/",
|
|
33455
|
-
dir:
|
|
33472
|
+
dir: import_path14.default.join(root, distDir, "client")
|
|
33456
33473
|
}
|
|
33457
33474
|
],
|
|
33458
33475
|
// Build configuration
|
|
@@ -33486,11 +33503,11 @@ export default defineEventHandler(async (event: H3Event) => {
|
|
|
33486
33503
|
function getNitroPreset(preset) {
|
|
33487
33504
|
return preset || "node-server";
|
|
33488
33505
|
}
|
|
33489
|
-
var
|
|
33506
|
+
var import_path14;
|
|
33490
33507
|
var init_nitro = __esm({
|
|
33491
33508
|
"src/nitro/index.ts"() {
|
|
33492
33509
|
"use strict";
|
|
33493
|
-
|
|
33510
|
+
import_path14 = __toESM(require("path"));
|
|
33494
33511
|
init_workflows();
|
|
33495
33512
|
init_cron();
|
|
33496
33513
|
init_route_rules();
|
|
@@ -35212,8 +35229,8 @@ function createAPIClient(options = {}) {
|
|
|
35212
35229
|
const inflightState = /* @__PURE__ */ new Map();
|
|
35213
35230
|
const routeMeta = /* @__PURE__ */ new WeakMap();
|
|
35214
35231
|
let requestCounter = 0;
|
|
35215
|
-
const fetchClient = /* @__PURE__ */ __name(async (
|
|
35216
|
-
const url = resolveFarmAPIRequestURL(
|
|
35232
|
+
const fetchClient = /* @__PURE__ */ __name(async (path38, requestOptions = {}) => {
|
|
35233
|
+
const url = resolveFarmAPIRequestURL(path38, baseURL);
|
|
35217
35234
|
if (requestOptions.query) {
|
|
35218
35235
|
Object.entries(requestOptions.query).forEach(([key, value]) => {
|
|
35219
35236
|
if (value !== void 0 && value !== null) {
|
|
@@ -35248,7 +35265,7 @@ function createAPIClient(options = {}) {
|
|
|
35248
35265
|
}
|
|
35249
35266
|
return { response, data };
|
|
35250
35267
|
}, "fetchClient");
|
|
35251
|
-
const request = /* @__PURE__ */ __name(async (
|
|
35268
|
+
const request = /* @__PURE__ */ __name(async (path38, method, input = {}, clientOptions) => {
|
|
35252
35269
|
const methodUpper = method.toUpperCase();
|
|
35253
35270
|
const requestId = `${Date.now()}-${++requestCounter}`;
|
|
35254
35271
|
const cacheOptions = clientOptions?.cache ? {
|
|
@@ -35257,7 +35274,7 @@ function createAPIClient(options = {}) {
|
|
|
35257
35274
|
} : void 0;
|
|
35258
35275
|
const configuredCacheKey = clientOptions?.key ?? cacheOptions?.key;
|
|
35259
35276
|
const cacheKey = normalizeFarmClientCacheKey(
|
|
35260
|
-
configuredCacheKey ?? buildCacheKey(methodUpper,
|
|
35277
|
+
configuredCacheKey ?? buildCacheKey(methodUpper, path38, input, baseURL, options.headers)
|
|
35261
35278
|
);
|
|
35262
35279
|
const now2 = Date.now();
|
|
35263
35280
|
const emitStatus = /* @__PURE__ */ __name((phase, payload) => {
|
|
@@ -35346,13 +35363,13 @@ function createAPIClient(options = {}) {
|
|
|
35346
35363
|
requestId,
|
|
35347
35364
|
method: methodUpper,
|
|
35348
35365
|
key: cacheKey,
|
|
35349
|
-
path:
|
|
35366
|
+
path: path38,
|
|
35350
35367
|
input,
|
|
35351
35368
|
attempt,
|
|
35352
35369
|
timestamp: Date.now()
|
|
35353
35370
|
});
|
|
35354
35371
|
try {
|
|
35355
|
-
const { response, data } = await fetchClient(
|
|
35372
|
+
const { response, data } = await fetchClient(path38, {
|
|
35356
35373
|
...input,
|
|
35357
35374
|
method: methodUpper
|
|
35358
35375
|
});
|
|
@@ -35361,7 +35378,7 @@ function createAPIClient(options = {}) {
|
|
|
35361
35378
|
requestId,
|
|
35362
35379
|
method: methodUpper,
|
|
35363
35380
|
key: cacheKey,
|
|
35364
|
-
path:
|
|
35381
|
+
path: path38,
|
|
35365
35382
|
input,
|
|
35366
35383
|
attempt,
|
|
35367
35384
|
timestamp: Date.now(),
|
|
@@ -35384,7 +35401,7 @@ function createAPIClient(options = {}) {
|
|
|
35384
35401
|
requestId,
|
|
35385
35402
|
method: methodUpper,
|
|
35386
35403
|
key: cacheKey,
|
|
35387
|
-
path:
|
|
35404
|
+
path: path38,
|
|
35388
35405
|
input,
|
|
35389
35406
|
attempt,
|
|
35390
35407
|
timestamp: Date.now(),
|
|
@@ -35489,17 +35506,17 @@ function createAPIClient(options = {}) {
|
|
|
35489
35506
|
);
|
|
35490
35507
|
}
|
|
35491
35508
|
__name(createAPIClient, "createAPIClient");
|
|
35492
|
-
function createNestedProxy(
|
|
35509
|
+
function createNestedProxy(path38, client, routeMeta, baseURL, sameOrigin, rootAliases) {
|
|
35493
35510
|
const target = /* @__PURE__ */ __name(() => {
|
|
35494
35511
|
}, "target");
|
|
35495
35512
|
const proxy = new Proxy(target, {
|
|
35496
35513
|
// When accessing a property (api.hello)
|
|
35497
35514
|
get(_target, prop) {
|
|
35498
35515
|
if (prop === FARM_API_ROUTE_REF_SYMBOL) {
|
|
35499
|
-
return
|
|
35516
|
+
return path38.length > 0;
|
|
35500
35517
|
}
|
|
35501
35518
|
if (prop === FARM_API_ROUTE_META_SYMBOL) {
|
|
35502
|
-
const metadata = resolveRouteMeta({ path:
|
|
35519
|
+
const metadata = resolveRouteMeta({ path: path38, baseURL });
|
|
35503
35520
|
const requestURL = resolveFarmAPIRequestURL(metadata.routePath, baseURL);
|
|
35504
35521
|
return Object.freeze({
|
|
35505
35522
|
path: `${requestURL.pathname}${requestURL.search}${requestURL.hash}`,
|
|
@@ -35508,14 +35525,14 @@ function createNestedProxy(path37, client, routeMeta, baseURL, sameOrigin, rootA
|
|
|
35508
35525
|
sameOrigin
|
|
35509
35526
|
});
|
|
35510
35527
|
}
|
|
35511
|
-
if (
|
|
35528
|
+
if (path38.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
|
|
35512
35529
|
return rootAliases[prop];
|
|
35513
35530
|
}
|
|
35514
35531
|
if (typeof prop !== "string") {
|
|
35515
35532
|
return Reflect.get(_target, prop);
|
|
35516
35533
|
}
|
|
35517
35534
|
return createNestedProxy(
|
|
35518
|
-
[...
|
|
35535
|
+
[...path38, prop],
|
|
35519
35536
|
client,
|
|
35520
35537
|
routeMeta,
|
|
35521
35538
|
baseURL,
|
|
@@ -35525,21 +35542,21 @@ function createNestedProxy(path37, client, routeMeta, baseURL, sameOrigin, rootA
|
|
|
35525
35542
|
},
|
|
35526
35543
|
// When calling as a function
|
|
35527
35544
|
apply(_target, _thisArg, args) {
|
|
35528
|
-
const lastPart =
|
|
35545
|
+
const lastPart = path38[path38.length - 1];
|
|
35529
35546
|
const httpMethods = ["get", "head", "query", "post", "put", "delete", "patch", "options"];
|
|
35530
35547
|
if (httpMethods.includes(lastPart)) {
|
|
35531
|
-
const routePath = "/api/" +
|
|
35548
|
+
const routePath = "/api/" + path38.slice(0, -1).join("/");
|
|
35532
35549
|
const method = lastPart.toUpperCase();
|
|
35533
35550
|
const [options, clientOptions] = args;
|
|
35534
35551
|
return client(routePath, method, options, clientOptions);
|
|
35535
35552
|
} else {
|
|
35536
|
-
const routePath = "/api/" +
|
|
35553
|
+
const routePath = "/api/" + path38.join("/");
|
|
35537
35554
|
const [options, clientOptions] = args;
|
|
35538
35555
|
return client(routePath, options?.method || "GET", options, clientOptions);
|
|
35539
35556
|
}
|
|
35540
35557
|
}
|
|
35541
35558
|
});
|
|
35542
|
-
routeMeta.set(proxy, { path: [...
|
|
35559
|
+
routeMeta.set(proxy, { path: [...path38], baseURL });
|
|
35543
35560
|
return proxy;
|
|
35544
35561
|
}
|
|
35545
35562
|
__name(createNestedProxy, "createNestedProxy");
|
|
@@ -35579,7 +35596,7 @@ function createServerAPIClient(endpoints, options = {}) {
|
|
|
35579
35596
|
return endpoints;
|
|
35580
35597
|
}
|
|
35581
35598
|
__name(createServerAPIClient, "createServerAPIClient");
|
|
35582
|
-
function buildCacheKey(method,
|
|
35599
|
+
function buildCacheKey(method, path38, input, baseURL, defaultHeaders) {
|
|
35583
35600
|
const keyInput = input && typeof input === "object" ? {
|
|
35584
35601
|
query: input.query,
|
|
35585
35602
|
body: input.body,
|
|
@@ -35588,7 +35605,7 @@ function buildCacheKey(method, path37, input, baseURL, defaultHeaders) {
|
|
|
35588
35605
|
contentEncoding: getHeader(input.headers, "content-encoding") ?? getHeader(defaultHeaders, "content-encoding")
|
|
35589
35606
|
} : {}
|
|
35590
35607
|
} : input;
|
|
35591
|
-
const url = resolveFarmAPIRequestURL(
|
|
35608
|
+
const url = resolveFarmAPIRequestURL(path38, baseURL);
|
|
35592
35609
|
return `${method}:${url.origin}${url.pathname}:${stableStringify(keyInput ?? {})}`;
|
|
35593
35610
|
}
|
|
35594
35611
|
__name(buildCacheKey, "buildCacheKey");
|
|
@@ -35836,7 +35853,7 @@ function farmApiPlugin(options = {}) {
|
|
|
35836
35853
|
configureServer(server) {
|
|
35837
35854
|
const discoverFileRoutes = /* @__PURE__ */ __name(async (apiDir) => {
|
|
35838
35855
|
const fs13 = await import("fs");
|
|
35839
|
-
const
|
|
35856
|
+
const path38 = await import("path");
|
|
35840
35857
|
if (!fs13.existsSync(apiDir)) {
|
|
35841
35858
|
log("No api directory found");
|
|
35842
35859
|
return;
|
|
@@ -35846,7 +35863,7 @@ function farmApiPlugin(options = {}) {
|
|
|
35846
35863
|
if (!fs13.existsSync(dir)) return files;
|
|
35847
35864
|
const entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
35848
35865
|
for (const entry of entries) {
|
|
35849
|
-
const fullPath =
|
|
35866
|
+
const fullPath = path38.join(dir, entry.name);
|
|
35850
35867
|
if (entry.isDirectory()) {
|
|
35851
35868
|
files.push(...findRouteFiles(fullPath));
|
|
35852
35869
|
} else if (entry.name === "route.ts" || entry.name === "route.tsx" || entry.name === "route.js") {
|
|
@@ -35859,7 +35876,7 @@ function farmApiPlugin(options = {}) {
|
|
|
35859
35876
|
apiRoutesCache.clear();
|
|
35860
35877
|
for (const filePath of routeFiles) {
|
|
35861
35878
|
try {
|
|
35862
|
-
const relativePath2 =
|
|
35879
|
+
const relativePath2 = path38.relative(apiDir, path38.dirname(filePath));
|
|
35863
35880
|
const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
|
|
35864
35881
|
const routeModule = await server.ssrLoadModule(filePath);
|
|
35865
35882
|
const endpoints = {};
|
|
@@ -35886,11 +35903,11 @@ function farmApiPlugin(options = {}) {
|
|
|
35886
35903
|
}, "discoverFileRoutes");
|
|
35887
35904
|
const discoverRootRoutes = /* @__PURE__ */ __name(async () => {
|
|
35888
35905
|
const fs13 = await import("fs");
|
|
35889
|
-
const
|
|
35906
|
+
const path38 = await import("path");
|
|
35890
35907
|
const routesFiles = [
|
|
35891
|
-
|
|
35892
|
-
|
|
35893
|
-
|
|
35908
|
+
path38.join(server.config.root, srcDir, "routes.ts"),
|
|
35909
|
+
path38.join(server.config.root, srcDir, "routes.tsx"),
|
|
35910
|
+
path38.join(server.config.root, srcDir, "routes.js")
|
|
35894
35911
|
];
|
|
35895
35912
|
for (const routesFile of routesFiles) {
|
|
35896
35913
|
if (fs13.existsSync(routesFile)) {
|
|
@@ -35913,8 +35930,8 @@ function farmApiPlugin(options = {}) {
|
|
|
35913
35930
|
}
|
|
35914
35931
|
}, "discoverRootRoutes");
|
|
35915
35932
|
const discoverProgrammaticRoutes = /* @__PURE__ */ __name(async () => {
|
|
35916
|
-
const
|
|
35917
|
-
const srcRoot =
|
|
35933
|
+
const path38 = await import("path");
|
|
35934
|
+
const srcRoot = path38.join(server.config.root, srcDir);
|
|
35918
35935
|
const routeFiles = findProgrammaticRouteFilesInDir(srcRoot);
|
|
35919
35936
|
if (routeFiles.length === 0) return;
|
|
35920
35937
|
const { getProgrammaticRouteManifest: getProgrammaticRouteManifest2 } = await Promise.resolve().then(() => (init_routes(), routes_exports));
|
|
@@ -35940,8 +35957,8 @@ function farmApiPlugin(options = {}) {
|
|
|
35940
35957
|
}
|
|
35941
35958
|
}, "discoverProgrammaticRoutes");
|
|
35942
35959
|
const initializeDiscovery = /* @__PURE__ */ __name(async () => {
|
|
35943
|
-
const
|
|
35944
|
-
const apiDir =
|
|
35960
|
+
const path38 = await import("path");
|
|
35961
|
+
const apiDir = path38.join(server.config.root, srcDir, "api");
|
|
35945
35962
|
log(`Discovering API routes in: ${apiDir}`);
|
|
35946
35963
|
await discoverFileRoutes(apiDir);
|
|
35947
35964
|
await discoverRootRoutes();
|
|
@@ -36110,9 +36127,9 @@ function farmApiPlugin(options = {}) {
|
|
|
36110
36127
|
}
|
|
36111
36128
|
} else {
|
|
36112
36129
|
try {
|
|
36113
|
-
const
|
|
36114
|
-
const apiDir =
|
|
36115
|
-
const relativePath2 =
|
|
36130
|
+
const path38 = await import("path");
|
|
36131
|
+
const apiDir = path38.join(server.config.root, srcDir, "api");
|
|
36132
|
+
const relativePath2 = path38.relative(apiDir, path38.dirname(file));
|
|
36116
36133
|
const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
|
|
36117
36134
|
const routeModule = await server.ssrLoadModule(file);
|
|
36118
36135
|
const endpoints = {};
|
|
@@ -36553,8 +36570,8 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
|
|
|
36553
36570
|
/**
|
|
36554
36571
|
* Set the base path for this middleware chain (called by manager when loading)
|
|
36555
36572
|
*/
|
|
36556
|
-
setBasePath(
|
|
36557
|
-
this.basePath =
|
|
36573
|
+
setBasePath(path38) {
|
|
36574
|
+
this.basePath = path38 === "/" ? "/" : path38.endsWith("/") ? path38.slice(0, -1) : path38;
|
|
36558
36575
|
}
|
|
36559
36576
|
use(fn) {
|
|
36560
36577
|
this.handlers.push(fn);
|
|
@@ -37569,12 +37586,12 @@ function isFarmRouteActive(pattern, pathname, options = {}) {
|
|
|
37569
37586
|
__name(isFarmRouteActive, "isFarmRouteActive");
|
|
37570
37587
|
function normalizeRouteInput(input, index) {
|
|
37571
37588
|
const route2 = typeof input === "string" ? { path: input } : input;
|
|
37572
|
-
const
|
|
37573
|
-
const segments = parseRoutePattern(
|
|
37589
|
+
const path38 = normalizePathname3(route2.path);
|
|
37590
|
+
const segments = parseRoutePattern(path38);
|
|
37574
37591
|
return {
|
|
37575
37592
|
route: {
|
|
37576
37593
|
...route2,
|
|
37577
|
-
path:
|
|
37594
|
+
path: path38
|
|
37578
37595
|
},
|
|
37579
37596
|
segments,
|
|
37580
37597
|
score: scoreSegments(segments),
|
|
@@ -38626,7 +38643,7 @@ init_generate_route_types();
|
|
|
38626
38643
|
|
|
38627
38644
|
// src/build/index.ts
|
|
38628
38645
|
init_config4();
|
|
38629
|
-
var
|
|
38646
|
+
var import_path15 = __toESM(require("path"));
|
|
38630
38647
|
var import_node_fs13 = require("fs");
|
|
38631
38648
|
init_utils();
|
|
38632
38649
|
init_app();
|
|
@@ -38635,9 +38652,61 @@ init_layers();
|
|
|
38635
38652
|
|
|
38636
38653
|
// src/nitro/universal-build.ts
|
|
38637
38654
|
init_config4();
|
|
38655
|
+
|
|
38656
|
+
// src/nitro/client-css-href.ts
|
|
38657
|
+
var import_path10 = __toESM(require("path"));
|
|
38658
|
+
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
38659
|
+
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
38660
|
+
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
38661
|
+
const fs13 = await import("fs/promises");
|
|
38662
|
+
try {
|
|
38663
|
+
const bytes = await fs13.readFile(sourcePath);
|
|
38664
|
+
if (bytes.length === 0) return null;
|
|
38665
|
+
const { createHash: createHash5 } = await import("crypto");
|
|
38666
|
+
const hash = createHash5("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
38667
|
+
const name2 = hashedName(hash);
|
|
38668
|
+
await fs13.mkdir(destinationDir, { recursive: true });
|
|
38669
|
+
await fs13.writeFile(import_path10.default.join(destinationDir, name2), bytes);
|
|
38670
|
+
return name2;
|
|
38671
|
+
} catch {
|
|
38672
|
+
return null;
|
|
38673
|
+
}
|
|
38674
|
+
}
|
|
38675
|
+
__name(hashAndCopy, "hashAndCopy");
|
|
38676
|
+
async function resolveHashedClientCssHref(clientOutputDir) {
|
|
38677
|
+
const name2 = await hashAndCopy(
|
|
38678
|
+
import_path10.default.join(clientOutputDir, "farm-client.css"),
|
|
38679
|
+
import_path10.default.join(clientOutputDir, "assets"),
|
|
38680
|
+
(hash) => `farm-client-h${hash}.css`
|
|
38681
|
+
);
|
|
38682
|
+
return name2 ? `/assets/${name2}` : "/farm-client.css";
|
|
38683
|
+
}
|
|
38684
|
+
__name(resolveHashedClientCssHref, "resolveHashedClientCssHref");
|
|
38685
|
+
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
38686
|
+
const fs13 = await import("fs/promises");
|
|
38687
|
+
try {
|
|
38688
|
+
const entries = await fs13.readdir(clientOutputDir);
|
|
38689
|
+
return entries.find((name2) => /^farm-client-h[0-9a-f]+\.js$/.test(name2)) ?? null;
|
|
38690
|
+
} catch {
|
|
38691
|
+
return null;
|
|
38692
|
+
}
|
|
38693
|
+
}
|
|
38694
|
+
__name(findFingerprintedClientEntry, "findFingerprintedClientEntry");
|
|
38695
|
+
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
38696
|
+
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
38697
|
+
if (!entryName) return "/farm-client.js";
|
|
38698
|
+
const fs13 = await import("fs/promises");
|
|
38699
|
+
const shim = `export * from "./${entryName}";
|
|
38700
|
+
`;
|
|
38701
|
+
await fs13.writeFile(import_path10.default.join(clientOutputDir, "farm-client.js"), shim);
|
|
38702
|
+
return `/${entryName}`;
|
|
38703
|
+
}
|
|
38704
|
+
__name(resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
|
|
38705
|
+
|
|
38706
|
+
// src/nitro/universal-build.ts
|
|
38638
38707
|
init_client_plugin_build();
|
|
38639
38708
|
var import_os = __toESM(require("os"));
|
|
38640
|
-
var
|
|
38709
|
+
var import_path13 = __toESM(require("path"));
|
|
38641
38710
|
var import_fs5 = require("fs");
|
|
38642
38711
|
var import_url3 = require("url");
|
|
38643
38712
|
var import_module3 = require("module");
|
|
@@ -38655,13 +38724,13 @@ init_search_client();
|
|
|
38655
38724
|
init_fonts();
|
|
38656
38725
|
|
|
38657
38726
|
// src/route-runtime-manifest.ts
|
|
38658
|
-
var
|
|
38727
|
+
var import_path11 = __toESM(require("path"));
|
|
38659
38728
|
init_deployment();
|
|
38660
38729
|
init_route_runtime();
|
|
38661
38730
|
init_ssg();
|
|
38662
38731
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
38663
38732
|
async function createFarmRouteRuntimeManifest(options) {
|
|
38664
|
-
const root =
|
|
38733
|
+
const root = import_path11.default.resolve(options.root || options.config.root || process.cwd());
|
|
38665
38734
|
const routes = [];
|
|
38666
38735
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
38667
38736
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -38709,7 +38778,7 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
38709
38778
|
__name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
|
|
38710
38779
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
38711
38780
|
const fs13 = await import("fs/promises");
|
|
38712
|
-
const manifestPath =
|
|
38781
|
+
const manifestPath = import_path11.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
38713
38782
|
await fs13.mkdir(directory, { recursive: true });
|
|
38714
38783
|
await fs13.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
38715
38784
|
`);
|
|
@@ -38749,13 +38818,13 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
38749
38818
|
const queryIndex = modulePath.indexOf("?");
|
|
38750
38819
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
38751
38820
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
38752
|
-
const relativePath2 =
|
|
38821
|
+
const relativePath2 = import_path11.default.isAbsolute(filePath) ? import_path11.default.relative(root, filePath) : filePath;
|
|
38753
38822
|
return `${relativePath2.replace(/\\/g, "/")}${query}`;
|
|
38754
38823
|
}
|
|
38755
38824
|
__name(normalizeManifestSource, "normalizeManifestSource");
|
|
38756
38825
|
|
|
38757
38826
|
// src/nitro/vercel-route-runtime.ts
|
|
38758
|
-
var
|
|
38827
|
+
var import_path12 = __toESM(require("path"));
|
|
38759
38828
|
init_route_runtime();
|
|
38760
38829
|
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs13) {
|
|
38761
38830
|
const dynamicRoutes = manifest.routes.filter(
|
|
@@ -38776,8 +38845,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs13)
|
|
|
38776
38845
|
group.routes.push(route2);
|
|
38777
38846
|
groups.set(key, group);
|
|
38778
38847
|
}
|
|
38779
|
-
const functionsDir =
|
|
38780
|
-
const baseFunctionDir =
|
|
38848
|
+
const functionsDir = import_path12.default.join(outputDir, "functions");
|
|
38849
|
+
const baseFunctionDir = import_path12.default.join(functionsDir, "__nitro.func");
|
|
38781
38850
|
const destinations = /* @__PURE__ */ new Map();
|
|
38782
38851
|
let groupIndex = 0;
|
|
38783
38852
|
for (const [key, group] of groups) {
|
|
@@ -38787,7 +38856,7 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs13)
|
|
|
38787
38856
|
}
|
|
38788
38857
|
groupIndex += 1;
|
|
38789
38858
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
38790
|
-
const functionDir =
|
|
38859
|
+
const functionDir = import_path12.default.join(functionsDir, `${functionName}.func`);
|
|
38791
38860
|
await fs13.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
38792
38861
|
await configureVercelFunction(functionDir, group.config, fs13);
|
|
38793
38862
|
destinations.set(key, `/${functionName}`);
|
|
@@ -38837,7 +38906,7 @@ function farmRoutePatternToVercelSource(pattern) {
|
|
|
38837
38906
|
}
|
|
38838
38907
|
__name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
|
|
38839
38908
|
async function configureVercelFunction(functionDir, config, fs13) {
|
|
38840
|
-
const configPath =
|
|
38909
|
+
const configPath = import_path12.default.join(functionDir, ".vc-config.json");
|
|
38841
38910
|
const current = JSON.parse(await fs13.readFile(configPath, "utf8"));
|
|
38842
38911
|
const next = {
|
|
38843
38912
|
...current,
|
|
@@ -38886,8 +38955,9 @@ function createFarmVercelImmutableAssetRoute(basePath = "/") {
|
|
|
38886
38955
|
const normalizedBasePath = normalizeBasePath3(basePath);
|
|
38887
38956
|
const escapedBasePath = escapeRegex2(normalizedBasePath);
|
|
38888
38957
|
const prefix = escapedBasePath ? `/${escapedBasePath}` : "";
|
|
38958
|
+
const fingerprint = "-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})";
|
|
38889
38959
|
return {
|
|
38890
|
-
src: `^${prefix}/(?:assets|chunks)/(?:.+/)*[^/]
|
|
38960
|
+
src: `^${prefix}/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-client)${fingerprint}\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$`,
|
|
38891
38961
|
headers: {
|
|
38892
38962
|
"Cache-Control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL
|
|
38893
38963
|
},
|
|
@@ -39209,7 +39279,7 @@ function preloadFarmNitroRuntime() {
|
|
|
39209
39279
|
}
|
|
39210
39280
|
__name(preloadFarmNitroRuntime, "preloadFarmNitroRuntime");
|
|
39211
39281
|
var _filename = typeof import_meta.url !== "undefined" ? (0, import_url3.fileURLToPath)(import_meta.url) : "";
|
|
39212
|
-
var _dirname =
|
|
39282
|
+
var _dirname = import_path13.default.dirname(_filename);
|
|
39213
39283
|
var NODE_BUILTIN_MODULES = /* @__PURE__ */ new Set([
|
|
39214
39284
|
...import_module3.builtinModules,
|
|
39215
39285
|
...import_module3.builtinModules.map((moduleName) => `node:${moduleName}`)
|
|
@@ -39238,14 +39308,14 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
39238
39308
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
39239
39309
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
39240
39310
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
39241
|
-
const projectRequire = (0, import_module3.createRequire)(
|
|
39311
|
+
const projectRequire = (0, import_module3.createRequire)(import_path13.default.join(root, "package.json"));
|
|
39242
39312
|
let runtimeRequire = projectRequire;
|
|
39243
39313
|
try {
|
|
39244
39314
|
runtimeRequire = (0, import_module3.createRequire)(projectRequire.resolve("@farm.js/core"));
|
|
39245
39315
|
} catch {
|
|
39246
39316
|
}
|
|
39247
39317
|
const nitroEntry = runtimeRequire.resolve("nitro");
|
|
39248
|
-
return (0, import_module3.createRequire)(nitroEntry).resolve(specifier).split(
|
|
39318
|
+
return (0, import_module3.createRequire)(nitroEntry).resolve(specifier).split(import_path13.default.sep).join("/");
|
|
39249
39319
|
}
|
|
39250
39320
|
__name(resolveNitroRuntimeDependency, "resolveNitroRuntimeDependency");
|
|
39251
39321
|
function cloneConfigValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
@@ -39339,7 +39409,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
39339
39409
|
return null;
|
|
39340
39410
|
}
|
|
39341
39411
|
const requestPath = source.slice(0, -"?module".length);
|
|
39342
|
-
const resolvedPath =
|
|
39412
|
+
const resolvedPath = import_path13.default.isAbsolute(requestPath) ? requestPath : import_path13.default.resolve(import_path13.default.dirname(importer.split("?", 1)[0]), requestPath);
|
|
39343
39413
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
39344
39414
|
},
|
|
39345
39415
|
load(id) {
|
|
@@ -39365,11 +39435,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
39365
39435
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
39366
39436
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
39367
39437
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
39368
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
39438
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? import_path13.default.posix.normalize(import_path13.default.posix.join(import_path13.default.posix.dirname(fileName), normalizedImportId)) : null;
|
|
39369
39439
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
39370
39440
|
continue;
|
|
39371
39441
|
}
|
|
39372
|
-
if (
|
|
39442
|
+
if (import_path13.default.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
39373
39443
|
externalPackages.add(importId);
|
|
39374
39444
|
continue;
|
|
39375
39445
|
}
|
|
@@ -39382,15 +39452,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
39382
39452
|
}
|
|
39383
39453
|
__name(collectSSRExternalPackages, "collectSSRExternalPackages");
|
|
39384
39454
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
39385
|
-
const resolvedNitroEntry =
|
|
39386
|
-
const resolvedSSREntry =
|
|
39455
|
+
const resolvedNitroEntry = import_path13.default.resolve(nitroEntryPath);
|
|
39456
|
+
const resolvedSSREntry = import_path13.default.resolve(ssrOutputDir, ssrEntryFile);
|
|
39387
39457
|
return {
|
|
39388
39458
|
name: "farm-externalize-prebuilt-ssr",
|
|
39389
39459
|
resolveId(source, importer) {
|
|
39390
|
-
if (!importer ||
|
|
39460
|
+
if (!importer || import_path13.default.resolve(importer) !== resolvedNitroEntry) {
|
|
39391
39461
|
return null;
|
|
39392
39462
|
}
|
|
39393
|
-
const resolvedImport =
|
|
39463
|
+
const resolvedImport = import_path13.default.resolve(import_path13.default.dirname(importer), source);
|
|
39394
39464
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
39395
39465
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
39396
39466
|
}
|
|
@@ -39479,13 +39549,13 @@ function resolveBuildDocsContentDir(config, root) {
|
|
|
39479
39549
|
if (!config.docs?.enabled) return null;
|
|
39480
39550
|
const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
|
|
39481
39551
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
39482
|
-
const contentDir =
|
|
39552
|
+
const contentDir = import_path13.default.isAbsolute(configuredContentDir) ? configuredContentDir : import_path13.default.join(root, configuredContentDir);
|
|
39483
39553
|
return (0, import_fs5.existsSync)(contentDir) ? contentDir : null;
|
|
39484
39554
|
}
|
|
39485
39555
|
const entryDir = config.docs.config.entry || trimSlashes3(config.docs.entry) || "docs";
|
|
39486
|
-
const appDocsDir =
|
|
39556
|
+
const appDocsDir = import_path13.default.join(root, config.srcDir || "src", "app", entryDir);
|
|
39487
39557
|
if ((0, import_fs5.existsSync)(appDocsDir)) return appDocsDir;
|
|
39488
|
-
const rootDocsDir =
|
|
39558
|
+
const rootDocsDir = import_path13.default.join(root, entryDir);
|
|
39489
39559
|
return (0, import_fs5.existsSync)(rootDocsDir) ? rootDocsDir : null;
|
|
39490
39560
|
}
|
|
39491
39561
|
__name(resolveBuildDocsContentDir, "resolveBuildDocsContentDir");
|
|
@@ -39503,7 +39573,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
39503
39573
|
".postcssrc.mjs",
|
|
39504
39574
|
".postcssrc.ts"
|
|
39505
39575
|
];
|
|
39506
|
-
const projectRequire = (0, import_module3.createRequire)(
|
|
39576
|
+
const projectRequire = (0, import_module3.createRequire)(import_path13.default.join(root, "package.json"));
|
|
39507
39577
|
return candidates.some((file) => {
|
|
39508
39578
|
try {
|
|
39509
39579
|
projectRequire.resolve(`./${file}`);
|
|
@@ -39527,7 +39597,7 @@ async function findFarmConfigPath(root) {
|
|
|
39527
39597
|
"config.mjs"
|
|
39528
39598
|
];
|
|
39529
39599
|
for (const candidate of candidates) {
|
|
39530
|
-
const resolvedPath =
|
|
39600
|
+
const resolvedPath = import_path13.default.join(root, candidate);
|
|
39531
39601
|
try {
|
|
39532
39602
|
await fs13.access(resolvedPath);
|
|
39533
39603
|
return resolvedPath;
|
|
@@ -39572,7 +39642,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
39572
39642
|
if (middlewareFile) {
|
|
39573
39643
|
discovered.push({
|
|
39574
39644
|
path: routePath,
|
|
39575
|
-
filePath:
|
|
39645
|
+
filePath: import_path13.default.join(dir, middlewareFile.name)
|
|
39576
39646
|
});
|
|
39577
39647
|
}
|
|
39578
39648
|
for (const entry of entries) {
|
|
@@ -39580,7 +39650,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
39580
39650
|
continue;
|
|
39581
39651
|
}
|
|
39582
39652
|
const childRoutePath = routePath === "/" ? `/${entry.name}` : `${routePath}/${entry.name}`;
|
|
39583
|
-
await walk(
|
|
39653
|
+
await walk(import_path13.default.join(dir, entry.name), childRoutePath, discovered);
|
|
39584
39654
|
}
|
|
39585
39655
|
}
|
|
39586
39656
|
__name(walk, "walk");
|
|
@@ -39645,7 +39715,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39645
39715
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
39646
39716
|
const fs13 = await import("fs/promises");
|
|
39647
39717
|
const layoutRoutes = [];
|
|
39648
|
-
const appDir =
|
|
39718
|
+
const appDir = import_path13.default.join(root, srcDir, "app");
|
|
39649
39719
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
39650
39720
|
try {
|
|
39651
39721
|
const entries = await fs13.readdir(dir, { withFileTypes: true });
|
|
@@ -39653,11 +39723,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39653
39723
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
39654
39724
|
layoutRoutes.push({
|
|
39655
39725
|
pattern: routePrefix,
|
|
39656
|
-
modulePath:
|
|
39726
|
+
modulePath: import_path13.default.join(dir, entry.name)
|
|
39657
39727
|
});
|
|
39658
39728
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
39659
39729
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
39660
|
-
await findLayoutsForClient(
|
|
39730
|
+
await findLayoutsForClient(import_path13.default.join(dir, entry.name), childPrefix);
|
|
39661
39731
|
}
|
|
39662
39732
|
}
|
|
39663
39733
|
} catch {
|
|
@@ -39672,7 +39742,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39672
39742
|
layoutRoutes.push({ pattern, modulePath: entry.modulePath });
|
|
39673
39743
|
}
|
|
39674
39744
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
39675
|
-
const clientOutputDir =
|
|
39745
|
+
const clientOutputDir = import_path13.default.join(root, distDir, "client");
|
|
39676
39746
|
const [productionViteResult] = await productionViteResultPromise;
|
|
39677
39747
|
if (productionViteResult.status === "rejected") {
|
|
39678
39748
|
await routeRuntimeManifestResultPromise;
|
|
@@ -39767,12 +39837,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39767
39837
|
lifecyclePluginManager
|
|
39768
39838
|
);
|
|
39769
39839
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
39770
|
-
|
|
39840
|
+
import_path13.default.join(root, distDir),
|
|
39771
39841
|
routeRuntimeManifest
|
|
39772
39842
|
);
|
|
39773
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
39774
|
-
logger.success("\u2705 Build completed successfully!");
|
|
39775
|
-
logger.info(`\u{1F4C1} Output directory: ${deployOutputDir}`);
|
|
39843
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${import_path13.default.relative(root, runtimeManifestPath)}`);
|
|
39776
39844
|
} catch (error) {
|
|
39777
39845
|
if (lifecyclePluginManager) {
|
|
39778
39846
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -39797,8 +39865,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
39797
39865
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
39798
39866
|
continue;
|
|
39799
39867
|
}
|
|
39800
|
-
const filePath =
|
|
39801
|
-
await fs13.mkdir(
|
|
39868
|
+
const filePath = import_path13.default.join(outputDir, fileName);
|
|
39869
|
+
await fs13.mkdir(import_path13.default.dirname(filePath), { recursive: true });
|
|
39802
39870
|
await fs13.writeFile(filePath, output.source);
|
|
39803
39871
|
}
|
|
39804
39872
|
}
|
|
@@ -39807,8 +39875,8 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
39807
39875
|
const fs13 = await import("fs/promises");
|
|
39808
39876
|
await Promise.all(
|
|
39809
39877
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
39810
|
-
const targetPath =
|
|
39811
|
-
await fs13.mkdir(
|
|
39878
|
+
const targetPath = import_path13.default.join(outputDir, url.replace(/^\/+/, ""));
|
|
39879
|
+
await fs13.mkdir(import_path13.default.dirname(targetPath), { recursive: true });
|
|
39812
39880
|
await fs13.copyFile(sourcePath, targetPath);
|
|
39813
39881
|
})
|
|
39814
39882
|
);
|
|
@@ -39816,7 +39884,7 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
39816
39884
|
__name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
39817
39885
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
39818
39886
|
const fs13 = await import("fs/promises");
|
|
39819
|
-
const fontCssPath =
|
|
39887
|
+
const fontCssPath = import_path13.default.join(outputDir, "farm-fonts.css");
|
|
39820
39888
|
let fontCss = fontCssSource;
|
|
39821
39889
|
if (fontCss === void 0) {
|
|
39822
39890
|
try {
|
|
@@ -39825,7 +39893,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
39825
39893
|
return;
|
|
39826
39894
|
}
|
|
39827
39895
|
}
|
|
39828
|
-
const clientCssPath =
|
|
39896
|
+
const clientCssPath = import_path13.default.join(outputDir, "farm-client.css");
|
|
39829
39897
|
let clientCss = "";
|
|
39830
39898
|
try {
|
|
39831
39899
|
clientCss = await fs13.readFile(clientCssPath, "utf8");
|
|
@@ -39846,7 +39914,8 @@ __name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
|
|
|
39846
39914
|
var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
39847
39915
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
39848
39916
|
const fs13 = await import("fs/promises");
|
|
39849
|
-
const
|
|
39917
|
+
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
39918
|
+
const clientEntryPath = import_path13.default.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
39850
39919
|
let clientEntrySize = 0;
|
|
39851
39920
|
try {
|
|
39852
39921
|
const clientEntry = await fs13.stat(clientEntryPath);
|
|
@@ -39856,8 +39925,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
39856
39925
|
if (clientEntrySize === 0) {
|
|
39857
39926
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
39858
39927
|
}
|
|
39859
|
-
const clientCssPath =
|
|
39860
|
-
const globalsCssPath =
|
|
39928
|
+
const clientCssPath = import_path13.default.join(outputDir, "farm-client.css");
|
|
39929
|
+
const globalsCssPath = import_path13.default.join(root, srcDir, "app", "globals.css");
|
|
39861
39930
|
let expectsCss = false;
|
|
39862
39931
|
try {
|
|
39863
39932
|
const globalsCss = await fs13.readFile(globalsCssPath, "utf8");
|
|
@@ -39988,10 +40057,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39988
40057
|
logger.info(
|
|
39989
40058
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout2) => layout2.shouldHydrate).length} layouts, and ${clientRouteSlots.length} slots`
|
|
39990
40059
|
);
|
|
39991
|
-
const clientEntryRoot =
|
|
40060
|
+
const clientEntryRoot = import_path13.default.join(root, ".farm", "tmp");
|
|
39992
40061
|
await fs13.mkdir(clientEntryRoot, { recursive: true });
|
|
39993
|
-
const clientEntryDir = await fs13.mkdtemp(
|
|
39994
|
-
const clientEntryPath =
|
|
40062
|
+
const clientEntryDir = await fs13.mkdtemp(import_path13.default.join(clientEntryRoot, "client-entry-"));
|
|
40063
|
+
const clientEntryPath = import_path13.default.join(clientEntryDir, "farm-client-entry.tsx");
|
|
39995
40064
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
39996
40065
|
clientPages,
|
|
39997
40066
|
clientLayouts,
|
|
@@ -40017,7 +40086,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
40017
40086
|
if (hasScopedPostcssConfig) {
|
|
40018
40087
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
40019
40088
|
} else {
|
|
40020
|
-
const postcssConfigPath =
|
|
40089
|
+
const postcssConfigPath = import_path13.default.join(clientEntryDir, "postcss.config.cjs");
|
|
40021
40090
|
await fs13.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
40022
40091
|
postcssSearchPath = clientEntryDir;
|
|
40023
40092
|
try {
|
|
@@ -40050,7 +40119,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
40050
40119
|
"farm-client": clientEntryPath
|
|
40051
40120
|
},
|
|
40052
40121
|
output: {
|
|
40053
|
-
entryFileNames: "[name].js",
|
|
40122
|
+
entryFileNames: "[name]-h[hash].js",
|
|
40054
40123
|
chunkFileNames: "chunks/[name]-h[hash].js",
|
|
40055
40124
|
hashCharacters: "hex",
|
|
40056
40125
|
// Use predictable name for CSS so we can reference it in SSR HTML
|
|
@@ -40368,7 +40437,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
|
|
|
40368
40437
|
);
|
|
40369
40438
|
const rendererClientImports = isReactRenderer(renderer) ? `import React from "react";
|
|
40370
40439
|
import { createRoot, hydrateRoot } from "react-dom/client";` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
|
|
40371
|
-
const globalsCssPath =
|
|
40440
|
+
const globalsCssPath = import_path13.default.join(root, srcDir, "app", "globals.css");
|
|
40372
40441
|
const cssImportPath = toImportPath(globalsCssPath);
|
|
40373
40442
|
const cssImport = `import ${JSON.stringify(cssImportPath)};`;
|
|
40374
40443
|
const layoutImportStatements = [];
|
|
@@ -41637,9 +41706,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41637
41706
|
ssr: true
|
|
41638
41707
|
});
|
|
41639
41708
|
if (!hasScopedPostcssConfig) {
|
|
41640
|
-
postcssConfigDir = await fs13.mkdtemp(
|
|
41709
|
+
postcssConfigDir = await fs13.mkdtemp(import_path13.default.join(import_os.default.tmpdir(), "farm-postcss-"));
|
|
41641
41710
|
await fs13.writeFile(
|
|
41642
|
-
|
|
41711
|
+
import_path13.default.join(postcssConfigDir, "postcss.config.cjs"),
|
|
41643
41712
|
"module.exports = { plugins: [] };\n"
|
|
41644
41713
|
);
|
|
41645
41714
|
try {
|
|
@@ -41717,7 +41786,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41717
41786
|
const notFoundExtensions = getFarmRendererComponentExtensions(config.renderer);
|
|
41718
41787
|
for (const sourceAppDir of appDirs) {
|
|
41719
41788
|
for (const ext of notFoundExtensions) {
|
|
41720
|
-
const checkPath =
|
|
41789
|
+
const checkPath = import_path13.default.join(sourceAppDir, `not-found${ext}`);
|
|
41721
41790
|
try {
|
|
41722
41791
|
await fs13.access(checkPath);
|
|
41723
41792
|
notFoundPath = checkPath;
|
|
@@ -42149,7 +42218,7 @@ import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
|
|
|
42149
42218
|
import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
42150
42219
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse } from "@farm.js/core/markdown";` : "";
|
|
42151
42220
|
const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse } from "@farm.js/core/app-markdown";` : "const createFarmMarkdownSourceResponse = null;";
|
|
42152
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
42221
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? import_path13.default.isAbsolute(config.mdx.components) ? config.mdx.components : import_path13.default.join(config.root, config.mdx.components) : null;
|
|
42153
42222
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from "${mdxComponentsPath.replace(/\\/g, "/")}";` : "";
|
|
42154
42223
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
42155
42224
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -42424,8 +42493,8 @@ const farmDocsHandler = ${config.docs?.enabled ? adapterOwnsDocsRuntime ? `creat
|
|
|
42424
42493
|
contentDir: farmDocsResolvedConfig.contentDir || farmDocsResolvedConfig.config?.contentDir,
|
|
42425
42494
|
}, {
|
|
42426
42495
|
rootDir: farmDocsRuntimeRoot,
|
|
42427
|
-
clientEntry: "/
|
|
42428
|
-
stylesheets: ["/farm-fonts.css", "/
|
|
42496
|
+
clientEntry: "/__farm_client_js_src__",
|
|
42497
|
+
stylesheets: ["/farm-fonts.css", "/__farm_client_css_href__"],
|
|
42429
42498
|
resolveLayoutFonts: (pathname) =>
|
|
42430
42499
|
resolveFarmLayoutFonts(
|
|
42431
42500
|
getApplicableLayouts(getFarmRoutePathname(pathname)).map((layout) => layout.module),
|
|
@@ -42434,7 +42503,7 @@ const farmDocsHandler = ${config.docs?.enabled ? adapterOwnsDocsRuntime ? `creat
|
|
|
42434
42503
|
})` : `createFarmDocsHandler(farmDocsResolvedConfig, {
|
|
42435
42504
|
root: farmDocsRuntimeRoot,
|
|
42436
42505
|
srcDir: ${JSON.stringify(config.srcDir)},
|
|
42437
|
-
clientEntry: "/
|
|
42506
|
+
clientEntry: "/__farm_client_js_src__",
|
|
42438
42507
|
fontAssets: ${JSON.stringify(farmDocsFontAssets)},
|
|
42439
42508
|
resolveLayoutFonts: (pathname) =>
|
|
42440
42509
|
resolveFarmLayoutFonts(
|
|
@@ -42777,12 +42846,12 @@ function createFarmErrorDocument(html, title) {
|
|
|
42777
42846
|
' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
|
|
42778
42847
|
' <link rel="icon" href="data:,">\\n' +
|
|
42779
42848
|
' <title>' + escapedTitle + '</title>\\n' +
|
|
42780
|
-
' <link rel="stylesheet" href="/
|
|
42849
|
+
' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
|
|
42781
42850
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
42782
42851
|
'</head>\\n<body>\\n' +
|
|
42783
42852
|
' <div id="root">' + html + '</div>\\n' +
|
|
42784
42853
|
' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
42785
|
-
' <script type="module" src="/
|
|
42854
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n' +
|
|
42786
42855
|
'</body>\\n</html>';
|
|
42787
42856
|
}
|
|
42788
42857
|
|
|
@@ -42793,7 +42862,7 @@ function createFarmErrorDocument(html, title) {
|
|
|
42793
42862
|
.replace(/<\\/body>/i, '</div></body>');
|
|
42794
42863
|
}
|
|
42795
42864
|
fullHtml = fullHtml
|
|
42796
|
-
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/
|
|
42865
|
+
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
|
|
42797
42866
|
.replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
|
|
42798
42867
|
.replace(/<head([^>]*)>([\\s\\S]*?)<\\/head>/i, function(match, attrs, headContent) {
|
|
42799
42868
|
return headContent.includes("<title")
|
|
@@ -42803,7 +42872,7 @@ function createFarmErrorDocument(html, title) {
|
|
|
42803
42872
|
.replace(
|
|
42804
42873
|
/<\\/body>/i,
|
|
42805
42874
|
' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
42806
|
-
' <script type="module" src="/
|
|
42875
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
|
|
42807
42876
|
);
|
|
42808
42877
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
42809
42878
|
? fullHtml
|
|
@@ -43519,8 +43588,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
43519
43588
|
bodyMatch[0],
|
|
43520
43589
|
"<body" + bodyMatch[1] + ">" + rootMarkup + "</body>",
|
|
43521
43590
|
);
|
|
43522
|
-
if (!html.includes('href="/
|
|
43523
|
-
const clientStylesheet = ' <link rel="stylesheet" href="/
|
|
43591
|
+
if (!html.includes('href="/__farm_client_css_href__"')) {
|
|
43592
|
+
const clientStylesheet = ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n';
|
|
43524
43593
|
const firstStyleIndex = html.search(/<style(?:\\s|>)/i);
|
|
43525
43594
|
html =
|
|
43526
43595
|
firstStyleIndex >= 0
|
|
@@ -43530,10 +43599,10 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
43530
43599
|
if (!html.includes('id="__farm_route_slots_data__"')) {
|
|
43531
43600
|
html = html.replace(/<[/]body>/i, renderFarmClientBootstrapScript() + "\\n</body>");
|
|
43532
43601
|
}
|
|
43533
|
-
if (!html.includes('src="/
|
|
43602
|
+
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
43534
43603
|
html = html.replace(
|
|
43535
43604
|
/<[/]body>/i,
|
|
43536
|
-
' <script type="module" src="/
|
|
43605
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
|
|
43537
43606
|
);
|
|
43538
43607
|
}
|
|
43539
43608
|
if (!html.includes('window._$HY')) {
|
|
@@ -44263,8 +44332,8 @@ async function handleFarmRequestInContext(
|
|
|
44263
44332
|
' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
|
|
44264
44333
|
(hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
|
|
44265
44334
|
' <title>' + title + '</title>' + metaTags + '\\n' +
|
|
44266
|
-
' <link rel="stylesheet" href="/
|
|
44267
|
-
' <link rel="modulepreload" href="/
|
|
44335
|
+
' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
|
|
44336
|
+
' <link rel="modulepreload" href="/__farm_client_js_src__">\\n' +
|
|
44268
44337
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
44269
44338
|
'</head>\\n<body>\\n <div id="root">';
|
|
44270
44339
|
const streamSuffix = '</div>\\n' +
|
|
@@ -44273,7 +44342,7 @@ async function handleFarmRequestInContext(
|
|
|
44273
44342
|
routeSlotPayload,
|
|
44274
44343
|
clientPageProps
|
|
44275
44344
|
) + '\\n' +
|
|
44276
|
-
' <script type="module" src="/
|
|
44345
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n' +
|
|
44277
44346
|
'</body>\\n</html>';
|
|
44278
44347
|
const themedStreamPrefix = streamPrefix.replace(
|
|
44279
44348
|
'<html lang="en">',
|
|
@@ -44318,7 +44387,7 @@ async function handleFarmRequestInContext(
|
|
|
44318
44387
|
// Layout provides full HTML structure - inject CSS and client script
|
|
44319
44388
|
fullHtml = html
|
|
44320
44389
|
// Inject CSS link after opening head tag or first meta tag
|
|
44321
|
-
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/
|
|
44390
|
+
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
|
|
44322
44391
|
.replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
|
|
44323
44392
|
// Inject title if not present and we have one
|
|
44324
44393
|
.replace(/<head([^>]*)>([\\s\\S]*?)<\\/head>/i, (match, attrs, headContent) => {
|
|
@@ -44339,7 +44408,7 @@ async function handleFarmRequestInContext(
|
|
|
44339
44408
|
routeSlotPayload,
|
|
44340
44409
|
clientPageProps
|
|
44341
44410
|
) + '\\n' +
|
|
44342
|
-
' <script type="module" src="/
|
|
44411
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
|
|
44343
44412
|
);
|
|
44344
44413
|
|
|
44345
44414
|
// Add DOCTYPE if not present
|
|
@@ -44355,13 +44424,13 @@ async function handleFarmRequestInContext(
|
|
|
44355
44424
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
44356
44425
|
\${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
|
|
44357
44426
|
<title>\${title}</title>\${metaTags}
|
|
44358
|
-
<link rel="stylesheet" href="/
|
|
44427
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">
|
|
44359
44428
|
\${renderFarmRendererHydrationScript()}
|
|
44360
44429
|
</head>
|
|
44361
44430
|
<body>
|
|
44362
44431
|
<div id="root">\${html}</div>
|
|
44363
44432
|
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, routeSlotPayload, clientPageProps)}
|
|
44364
|
-
<script type="module" src="/
|
|
44433
|
+
<script type="module" src="/__farm_client_js_src__"></script>
|
|
44365
44434
|
</body>
|
|
44366
44435
|
</html>\`;
|
|
44367
44436
|
}
|
|
@@ -44620,12 +44689,12 @@ async function handleFarmRequestInContext(
|
|
|
44620
44689
|
let fullHtml;
|
|
44621
44690
|
if (hasFullDocument) {
|
|
44622
44691
|
fullHtml = html
|
|
44623
|
-
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/
|
|
44692
|
+
.replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
|
|
44624
44693
|
.replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
|
|
44625
44694
|
.replace(
|
|
44626
44695
|
/<\\/body>/i,
|
|
44627
44696
|
' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
44628
|
-
' <script type="module" src="/
|
|
44697
|
+
' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
|
|
44629
44698
|
);
|
|
44630
44699
|
if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
|
|
44631
44700
|
fullHtml = '<!DOCTYPE html>\\n' + fullHtml;
|
|
@@ -44637,14 +44706,14 @@ async function handleFarmRequestInContext(
|
|
|
44637
44706
|
<meta charset="UTF-8">
|
|
44638
44707
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
44639
44708
|
<link rel="icon" href="data:,">
|
|
44640
|
-
<link rel="stylesheet" href="/
|
|
44709
|
+
<link rel="stylesheet" href="/__farm_client_css_href__">
|
|
44641
44710
|
<title>404 - Page Not Found</title>
|
|
44642
44711
|
\${renderFarmRendererHydrationScript()}
|
|
44643
44712
|
</head>
|
|
44644
44713
|
<body>
|
|
44645
44714
|
<div id="root">\${html}</div>
|
|
44646
44715
|
\${renderFarmClientBootstrapScript()}
|
|
44647
|
-
<script type="module" src="/
|
|
44716
|
+
<script type="module" src="/__farm_client_js_src__"></script>
|
|
44648
44717
|
</body>
|
|
44649
44718
|
</html>\`;
|
|
44650
44719
|
}
|
|
@@ -44981,7 +45050,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
44981
45050
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
44982
45051
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
44983
45052
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
44984
|
-
const ssrOutputDir =
|
|
45053
|
+
const ssrOutputDir = import_path13.default.join(root, distDir, "ssr");
|
|
44985
45054
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
44986
45055
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
44987
45056
|
(image) => image.sourceType === "module"
|
|
@@ -45050,13 +45119,26 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
45050
45119
|
}
|
|
45051
45120
|
const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
|
|
45052
45121
|
const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
|
|
45122
|
+
const [clientCssHref, clientJsSrc] = await Promise.all([
|
|
45123
|
+
resolveHashedClientCssHref(clientOutputDir),
|
|
45124
|
+
resolveHashedClientJsSrc(clientOutputDir)
|
|
45125
|
+
]);
|
|
45126
|
+
for (const output of Object.values(ssrBundle)) {
|
|
45127
|
+
if (output.type !== "chunk") continue;
|
|
45128
|
+
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
45129
|
+
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
45130
|
+
}
|
|
45131
|
+
if (output.code.includes(FARM_CLIENT_JS_SRC_PLACEHOLDER)) {
|
|
45132
|
+
output.code = output.code.split(FARM_CLIENT_JS_SRC_PLACEHOLDER).join(clientJsSrc);
|
|
45133
|
+
}
|
|
45134
|
+
}
|
|
45053
45135
|
await fs13.mkdir(ssrOutputDir, { recursive: true });
|
|
45054
45136
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
45055
|
-
const filePath =
|
|
45056
|
-
await fs13.mkdir(
|
|
45137
|
+
const filePath = import_path13.default.join(ssrOutputDir, fileName);
|
|
45138
|
+
await fs13.mkdir(import_path13.default.dirname(filePath), { recursive: true });
|
|
45057
45139
|
await fs13.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
45058
45140
|
}
|
|
45059
|
-
const nitroEntryPath =
|
|
45141
|
+
const nitroEntryPath = import_path13.default.join(ssrOutputDir, "nitro-entry.mjs");
|
|
45060
45142
|
const nitroEntryCode = `
|
|
45061
45143
|
// Farm.js Nitro Entry
|
|
45062
45144
|
// This file adapts Farm's Web fetch handler to Nitro's event handler contract.
|
|
@@ -45121,12 +45203,12 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45121
45203
|
}
|
|
45122
45204
|
`.trim();
|
|
45123
45205
|
await fs13.writeFile(nitroEntryPath, nitroEntryCode);
|
|
45124
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
45206
|
+
const farmNodeServerEntryPath = preset === "node-server" ? import_path13.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
45125
45207
|
if (farmNodeServerEntryPath) {
|
|
45126
45208
|
await fs13.writeFile(
|
|
45127
45209
|
farmNodeServerEntryPath,
|
|
45128
45210
|
createFarmNodeServerEntry({
|
|
45129
|
-
nitroEntryFile:
|
|
45211
|
+
nitroEntryFile: import_path13.default.basename(nitroEntryPath),
|
|
45130
45212
|
nodeHandlerModule: resolveNitroRuntimeDependency(root, "srvx/node"),
|
|
45131
45213
|
server: config.server,
|
|
45132
45214
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
@@ -45160,12 +45242,12 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45160
45242
|
...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
|
|
45161
45243
|
rootDir: root,
|
|
45162
45244
|
srcDir: root,
|
|
45163
|
-
buildDir:
|
|
45245
|
+
buildDir: import_path13.default.join(root, distDir, ".nitro"),
|
|
45164
45246
|
compatibilityDate: "2024-12-01",
|
|
45165
45247
|
output: {
|
|
45166
45248
|
dir: outputDir,
|
|
45167
|
-
serverDir:
|
|
45168
|
-
publicDir:
|
|
45249
|
+
serverDir: import_path13.default.join(outputDir, "server"),
|
|
45250
|
+
publicDir: import_path13.default.join(outputDir, "public")
|
|
45169
45251
|
},
|
|
45170
45252
|
publicAssets: [
|
|
45171
45253
|
{
|
|
@@ -45250,7 +45332,7 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45250
45332
|
if (pluginManager) {
|
|
45251
45333
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
45252
45334
|
}
|
|
45253
|
-
const expectedServerDir =
|
|
45335
|
+
const expectedServerDir = import_path13.default.join(outputDir, "server");
|
|
45254
45336
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
45255
45337
|
(key) => key !== "external" && key !== "plugins"
|
|
45256
45338
|
);
|
|
@@ -45266,9 +45348,9 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45266
45348
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
45267
45349
|
);
|
|
45268
45350
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
45269
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 &&
|
|
45351
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && import_path13.default.resolve(nitroConfig.output?.serverDir || "") === import_path13.default.resolve(expectedServerDir) && Boolean(
|
|
45270
45352
|
nitroConfig.handlers?.some(
|
|
45271
|
-
(handler) =>
|
|
45353
|
+
(handler) => import_path13.default.resolve(handler?.handler || "") === nitroEntryPath
|
|
45272
45354
|
)
|
|
45273
45355
|
);
|
|
45274
45356
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -45280,8 +45362,9 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45280
45362
|
...configuredEsbuildOptions,
|
|
45281
45363
|
// Function-name helpers are unsafe for provider scripts that serialize a
|
|
45282
45364
|
// function with toString(); the helper is outside the emitted script scope.
|
|
45283
|
-
keepNames:
|
|
45365
|
+
keepNames: config.docs?.enabled && config.docs.adapter?.server ? false : configuredEsbuildOptions.keepNames ?? true
|
|
45284
45366
|
};
|
|
45367
|
+
const prebuiltSSREsbuildOptions = config.docs?.enabled && config.docs.adapter?.server ? resolvedEsbuildOptions : configuredEsbuildOptions;
|
|
45285
45368
|
const effectiveMinify = configuredEsbuildOptions.minify ?? shouldMinify;
|
|
45286
45369
|
const useFarmEsbuildMinifier = effectiveMinify && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig;
|
|
45287
45370
|
const esbuildChunkMinifier = useFarmEsbuildMinifier ? createEsbuildChunkMinifyPlugin(resolvedEsbuildOptions) : null;
|
|
@@ -45323,10 +45406,10 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45323
45406
|
});
|
|
45324
45407
|
}
|
|
45325
45408
|
prerenderer.hooks.hook("compiled", async () => {
|
|
45326
|
-
const prerenderServerDir =
|
|
45409
|
+
const prerenderServerDir = import_path13.default.join(outputDir, "server");
|
|
45327
45410
|
await copyPrebuiltSSRBundle(
|
|
45328
45411
|
ssrBundle,
|
|
45329
|
-
|
|
45412
|
+
import_path13.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
45330
45413
|
{},
|
|
45331
45414
|
false,
|
|
45332
45415
|
fs13
|
|
@@ -45360,20 +45443,20 @@ export default async function farmNitroEventHandler(event) {
|
|
|
45360
45443
|
const copyResults = await Promise.allSettled([
|
|
45361
45444
|
canReusePrebuiltSSR ? copyPrebuiltSSRBundle(
|
|
45362
45445
|
ssrBundle,
|
|
45363
|
-
|
|
45364
|
-
|
|
45446
|
+
import_path13.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
45447
|
+
prebuiltSSREsbuildOptions,
|
|
45365
45448
|
effectiveMinify,
|
|
45366
45449
|
fs13
|
|
45367
45450
|
) : Promise.resolve(),
|
|
45368
|
-
imageRuntime === "node" ? copySharpRuntime(config, root,
|
|
45369
|
-
useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root,
|
|
45451
|
+
imageRuntime === "node" ? copySharpRuntime(config, root, import_path13.default.join(outputDir, "server"), fs13) : Promise.resolve(),
|
|
45452
|
+
useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path13.default.join(outputDir, "server"), fs13) : Promise.resolve()
|
|
45370
45453
|
]);
|
|
45371
45454
|
const failedCopy = copyResults.find(
|
|
45372
45455
|
(result) => result.status === "rejected"
|
|
45373
45456
|
);
|
|
45374
45457
|
if (failedCopy) throw failedCopy.reason;
|
|
45375
45458
|
if (canReusePrebuiltSSR) {
|
|
45376
|
-
await registerPrebuiltSSRPackageImport(
|
|
45459
|
+
await registerPrebuiltSSRPackageImport(import_path13.default.join(outputDir, "server"), ssrEntryFile, fs13);
|
|
45377
45460
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
45378
45461
|
}
|
|
45379
45462
|
if (useRolldownBuilder) {
|
|
@@ -45413,8 +45496,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
|
|
|
45413
45496
|
await fs13.rm(targetDir, { recursive: true, force: true });
|
|
45414
45497
|
await Promise.all(
|
|
45415
45498
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
45416
|
-
const targetPath =
|
|
45417
|
-
await fs13.mkdir(
|
|
45499
|
+
const targetPath = import_path13.default.join(targetDir, fileName);
|
|
45500
|
+
await fs13.mkdir(import_path13.default.dirname(targetPath), { recursive: true });
|
|
45418
45501
|
if (output.type === "asset") {
|
|
45419
45502
|
await fs13.writeFile(targetPath, output.source);
|
|
45420
45503
|
return;
|
|
@@ -45433,7 +45516,7 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
|
|
|
45433
45516
|
}
|
|
45434
45517
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
45435
45518
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs13) {
|
|
45436
|
-
const packagePath =
|
|
45519
|
+
const packagePath = import_path13.default.join(serverDir, "package.json");
|
|
45437
45520
|
const packageJSON = await fs13.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
45438
45521
|
if (error.code === "ENOENT") return { type: "module" };
|
|
45439
45522
|
throw error;
|
|
@@ -45450,16 +45533,16 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs13) {
|
|
|
45450
45533
|
}
|
|
45451
45534
|
__name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
|
|
45452
45535
|
async function postProcessVercelOutput(root, outputDir, fs13, config, farmWorkflows, routeRuntimeManifest) {
|
|
45453
|
-
const serverDir =
|
|
45454
|
-
const functionsDir =
|
|
45455
|
-
const nitroFuncDir =
|
|
45456
|
-
const staticDir =
|
|
45457
|
-
const publicDir =
|
|
45536
|
+
const serverDir = import_path13.default.join(outputDir, "server");
|
|
45537
|
+
const functionsDir = import_path13.default.join(outputDir, "functions");
|
|
45538
|
+
const nitroFuncDir = import_path13.default.join(functionsDir, "__nitro.func");
|
|
45539
|
+
const staticDir = import_path13.default.join(outputDir, "static");
|
|
45540
|
+
const publicDir = import_path13.default.join(outputDir, "public");
|
|
45458
45541
|
await fs13.mkdir(nitroFuncDir, { recursive: true });
|
|
45459
45542
|
const serverContents = await fs13.readdir(serverDir);
|
|
45460
45543
|
for (const file of serverContents) {
|
|
45461
|
-
const src =
|
|
45462
|
-
const dest =
|
|
45544
|
+
const src = import_path13.default.join(serverDir, file);
|
|
45545
|
+
const dest = import_path13.default.join(nitroFuncDir, file);
|
|
45463
45546
|
await fs13.rename(src, dest);
|
|
45464
45547
|
}
|
|
45465
45548
|
await fs13.rmdir(serverDir);
|
|
@@ -45469,7 +45552,7 @@ async function postProcessVercelOutput(root, outputDir, fs13, config, farmWorkfl
|
|
|
45469
45552
|
}
|
|
45470
45553
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs13);
|
|
45471
45554
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs13);
|
|
45472
|
-
const configPath =
|
|
45555
|
+
const configPath = import_path13.default.join(outputDir, "config.json");
|
|
45473
45556
|
const configContent = await fs13.readFile(configPath, "utf-8");
|
|
45474
45557
|
const vercelConfig = JSON.parse(configContent);
|
|
45475
45558
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -45517,27 +45600,27 @@ __name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
|
45517
45600
|
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs13) {
|
|
45518
45601
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
45519
45602
|
if (!docsContentDir) return;
|
|
45520
|
-
const bundledContentDir =
|
|
45603
|
+
const bundledContentDir = import_path13.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
|
|
45521
45604
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
45522
45605
|
fallback: "now"
|
|
45523
45606
|
});
|
|
45524
45607
|
await fs13.rm(bundledContentDir, { recursive: true, force: true });
|
|
45525
|
-
await fs13.mkdir(
|
|
45608
|
+
await fs13.mkdir(import_path13.default.dirname(bundledContentDir), { recursive: true });
|
|
45526
45609
|
await fs13.cp(docsContentDir, bundledContentDir, {
|
|
45527
45610
|
recursive: true,
|
|
45528
45611
|
force: true
|
|
45529
45612
|
});
|
|
45530
45613
|
await fs13.writeFile(
|
|
45531
|
-
|
|
45614
|
+
import_path13.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
45532
45615
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
45533
45616
|
`
|
|
45534
45617
|
);
|
|
45535
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
45618
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path13.default.relative(root, docsContentDir)}`);
|
|
45536
45619
|
}
|
|
45537
45620
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
45538
45621
|
async function copySharpRuntime(config, root, nitroFuncDir, fs13) {
|
|
45539
45622
|
if (config.images.provider === "none") return;
|
|
45540
|
-
const projectRequire = (0, import_module3.createRequire)(
|
|
45623
|
+
const projectRequire = (0, import_module3.createRequire)(import_path13.default.join(root, "package.json"));
|
|
45541
45624
|
let sharpRequire = projectRequire;
|
|
45542
45625
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
45543
45626
|
try {
|
|
@@ -45547,7 +45630,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs13) {
|
|
|
45547
45630
|
}
|
|
45548
45631
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
45549
45632
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
45550
|
-
const targetNodeModules =
|
|
45633
|
+
const targetNodeModules = import_path13.default.join(nitroFuncDir, "node_modules");
|
|
45551
45634
|
function copyPackage(packageName, parentRequire) {
|
|
45552
45635
|
const activeCopy = packageCopies.get(packageName);
|
|
45553
45636
|
if (activeCopy) return activeCopy;
|
|
@@ -45560,10 +45643,10 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs13) {
|
|
|
45560
45643
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
45561
45644
|
if (!packageJsonPath) return;
|
|
45562
45645
|
const packageJson = JSON.parse(await fs13.readFile(packageJsonPath, "utf8"));
|
|
45563
|
-
const packageDir =
|
|
45564
|
-
const targetDir =
|
|
45646
|
+
const packageDir = import_path13.default.dirname(packageJsonPath);
|
|
45647
|
+
const targetDir = import_path13.default.join(targetNodeModules, ...packageName.split("/"));
|
|
45565
45648
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
45566
|
-
await fs13.mkdir(
|
|
45649
|
+
await fs13.mkdir(import_path13.default.dirname(targetDir), { recursive: true });
|
|
45567
45650
|
const packageRequire = (0, import_module3.createRequire)(packageJsonPath);
|
|
45568
45651
|
const dependencies = {
|
|
45569
45652
|
...packageJson.dependencies,
|
|
@@ -45588,7 +45671,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs13) {
|
|
|
45588
45671
|
"Farm image optimization requires sharp. Reinstall dependencies without omitting optional packages."
|
|
45589
45672
|
);
|
|
45590
45673
|
}
|
|
45591
|
-
const functionPackagePath =
|
|
45674
|
+
const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
|
|
45592
45675
|
const functionPackage = JSON.parse(await fs13.readFile(functionPackagePath, "utf8"));
|
|
45593
45676
|
functionPackage.dependencies = {
|
|
45594
45677
|
...functionPackage.dependencies,
|
|
@@ -45599,7 +45682,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs13) {
|
|
|
45599
45682
|
}
|
|
45600
45683
|
__name(copySharpRuntime, "copySharpRuntime");
|
|
45601
45684
|
async function copyMetadataImageRuntime(root, nitroFuncDir, fs13) {
|
|
45602
|
-
const projectRequire = (0, import_module3.createRequire)(
|
|
45685
|
+
const projectRequire = (0, import_module3.createRequire)(import_path13.default.join(root, "package.json"));
|
|
45603
45686
|
let runtimeRequire = projectRequire;
|
|
45604
45687
|
let packageJsonPath = resolvePackageJson(runtimeRequire, "@vercel/og");
|
|
45605
45688
|
if (!packageJsonPath) {
|
|
@@ -45615,16 +45698,16 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs13) {
|
|
|
45615
45698
|
);
|
|
45616
45699
|
}
|
|
45617
45700
|
const packageJson = JSON.parse(await fs13.readFile(packageJsonPath, "utf8"));
|
|
45618
|
-
const packageDir =
|
|
45619
|
-
const targetDir =
|
|
45620
|
-
await fs13.mkdir(
|
|
45701
|
+
const packageDir = import_path13.default.dirname(packageJsonPath);
|
|
45702
|
+
const targetDir = import_path13.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
45703
|
+
await fs13.mkdir(import_path13.default.dirname(targetDir), { recursive: true });
|
|
45621
45704
|
await fs13.cp(packageDir, targetDir, {
|
|
45622
45705
|
recursive: true,
|
|
45623
45706
|
force: true,
|
|
45624
45707
|
dereference: true,
|
|
45625
45708
|
mode: import_fs5.constants.COPYFILE_FICLONE
|
|
45626
45709
|
});
|
|
45627
|
-
const functionPackagePath =
|
|
45710
|
+
const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
|
|
45628
45711
|
const functionPackage = JSON.parse(await fs13.readFile(functionPackagePath, "utf8"));
|
|
45629
45712
|
functionPackage.dependencies = {
|
|
45630
45713
|
...functionPackage.dependencies,
|
|
@@ -45645,23 +45728,23 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
45645
45728
|
}
|
|
45646
45729
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
45647
45730
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs13) {
|
|
45648
|
-
const projectRequire = (0, import_module3.createRequire)(
|
|
45731
|
+
const projectRequire = (0, import_module3.createRequire)(import_path13.default.join(root, "package.json"));
|
|
45649
45732
|
let prismaClientDir;
|
|
45650
45733
|
try {
|
|
45651
|
-
prismaClientDir =
|
|
45734
|
+
prismaClientDir = import_path13.default.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
45652
45735
|
} catch {
|
|
45653
45736
|
return;
|
|
45654
45737
|
}
|
|
45655
|
-
const generatedClientDir =
|
|
45738
|
+
const generatedClientDir = import_path13.default.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
45656
45739
|
try {
|
|
45657
45740
|
await fs13.access(generatedClientDir);
|
|
45658
45741
|
} catch {
|
|
45659
45742
|
return;
|
|
45660
45743
|
}
|
|
45661
|
-
const targetNodeModules =
|
|
45662
|
-
const targetPrismaScopeDir =
|
|
45663
|
-
const targetGeneratedDir =
|
|
45664
|
-
const targetClientDir =
|
|
45744
|
+
const targetNodeModules = import_path13.default.join(nitroFuncDir, "node_modules");
|
|
45745
|
+
const targetPrismaScopeDir = import_path13.default.join(targetNodeModules, "@prisma");
|
|
45746
|
+
const targetGeneratedDir = import_path13.default.join(targetNodeModules, ".prisma", "client");
|
|
45747
|
+
const targetClientDir = import_path13.default.join(targetPrismaScopeDir, "client");
|
|
45665
45748
|
await fs13.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
45666
45749
|
await fs13.cp(prismaClientDir, targetClientDir, {
|
|
45667
45750
|
recursive: true,
|
|
@@ -45671,8 +45754,8 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs13) {
|
|
|
45671
45754
|
recursive: true,
|
|
45672
45755
|
force: true
|
|
45673
45756
|
});
|
|
45674
|
-
const functionPackagePath =
|
|
45675
|
-
const clientPackagePath =
|
|
45757
|
+
const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
|
|
45758
|
+
const clientPackagePath = import_path13.default.join(prismaClientDir, "package.json");
|
|
45676
45759
|
const [functionPackageContent, clientPackageContent] = await Promise.all([
|
|
45677
45760
|
fs13.readFile(functionPackagePath, "utf-8"),
|
|
45678
45761
|
fs13.readFile(clientPackagePath, "utf-8")
|
|
@@ -45787,7 +45870,9 @@ async function buildWithProductionNodeEnv(config, options) {
|
|
|
45787
45870
|
suppressLintOnLink: config.suppressLintOnLink,
|
|
45788
45871
|
componentExtensions: config.renderer.componentExtensions,
|
|
45789
45872
|
i18nConfig: config.i18n
|
|
45790
|
-
}).catch(() => {
|
|
45873
|
+
}).catch((error) => {
|
|
45874
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45875
|
+
logger.warn(`Route type generation failed (farm.d.ts may be stale): ${message}`);
|
|
45791
45876
|
});
|
|
45792
45877
|
const apiRouteManager = new APIRouteManager(
|
|
45793
45878
|
getFarmAppDirectories(config),
|
|
@@ -45813,9 +45898,9 @@ async function buildWithProductionNodeEnv(config, options) {
|
|
|
45813
45898
|
} else {
|
|
45814
45899
|
const { build: legacyViteBuild } = await import("vite");
|
|
45815
45900
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
45816
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
45901
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, import_path15.default.join(root, distDir, "client"));
|
|
45817
45902
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
45818
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
45903
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, import_path15.default.join(root, distDir, "server"));
|
|
45819
45904
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
45820
45905
|
await buildNitro(
|
|
45821
45906
|
config,
|
|
@@ -45837,7 +45922,7 @@ async function buildWithProductionNodeEnv(config, options) {
|
|
|
45837
45922
|
outputDir: deployOutputDir,
|
|
45838
45923
|
success: true
|
|
45839
45924
|
});
|
|
45840
|
-
logger.success(
|
|
45925
|
+
logger.success(`\u2705 Build completed successfully! (preset: ${preset})`);
|
|
45841
45926
|
logger.info(`\u{1F4C1} Output directory: ${deployOutputDir}`);
|
|
45842
45927
|
} catch (error) {
|
|
45843
45928
|
await pluginManager.runHookParallel("onError", {
|
|
@@ -45985,12 +46070,12 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
45985
46070
|
}
|
|
45986
46071
|
__name(buildSSR, "buildSSR");
|
|
45987
46072
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
45988
|
-
const appDir =
|
|
46073
|
+
const appDir = import_path15.default.join(root, srcDir, "app");
|
|
45989
46074
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
45990
|
-
const candidate =
|
|
46075
|
+
const candidate = import_path15.default.join(appDir, `page${extension}`);
|
|
45991
46076
|
if ((0, import_node_fs13.existsSync)(candidate)) return candidate;
|
|
45992
46077
|
}
|
|
45993
|
-
return
|
|
46078
|
+
return import_path15.default.join(appDir, "page.tsx");
|
|
45994
46079
|
}
|
|
45995
46080
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
45996
46081
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
@@ -46009,18 +46094,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
46009
46094
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
46010
46095
|
}
|
|
46011
46096
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
46012
|
-
const serverOutputDir =
|
|
46013
|
-
const publicOutputDir =
|
|
46097
|
+
const serverOutputDir = import_path15.default.join(outputDir, "server");
|
|
46098
|
+
const publicOutputDir = import_path15.default.join(outputDir, "public");
|
|
46014
46099
|
const { mkdir: mkdir2, cp } = await import("fs/promises");
|
|
46015
46100
|
await mkdir2(serverOutputDir, { recursive: true });
|
|
46016
46101
|
await mkdir2(publicOutputDir, { recursive: true });
|
|
46017
|
-
const clientDir =
|
|
46102
|
+
const clientDir = import_path15.default.join(root, distDir, "client");
|
|
46018
46103
|
try {
|
|
46019
46104
|
await mkdir2(publicOutputDir, { recursive: true });
|
|
46020
46105
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
46021
46106
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
46022
|
-
const manifestPath =
|
|
46023
|
-
const assetsDir =
|
|
46107
|
+
const manifestPath = import_path15.default.join(publicOutputDir, "farm-client-manifest.json");
|
|
46108
|
+
const assetsDir = import_path15.default.join(publicOutputDir, "assets");
|
|
46024
46109
|
const manifestExists = await import("fs/promises").then(
|
|
46025
46110
|
(fs13) => fs13.access(manifestPath).then(() => true).catch(() => false)
|
|
46026
46111
|
);
|
|
@@ -46036,8 +46121,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
46036
46121
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
46037
46122
|
throw error;
|
|
46038
46123
|
}
|
|
46039
|
-
const serverDir =
|
|
46040
|
-
const nitroServerDir =
|
|
46124
|
+
const serverDir = import_path15.default.join(root, distDir, "server");
|
|
46125
|
+
const nitroServerDir = import_path15.default.join(root, distDir, ".nitro", "server", "farm");
|
|
46041
46126
|
try {
|
|
46042
46127
|
await mkdir2(nitroServerDir, { recursive: true });
|
|
46043
46128
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -46046,7 +46131,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
46046
46131
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
46047
46132
|
}
|
|
46048
46133
|
const nitro = await createNitro(nitroConfig);
|
|
46049
|
-
const registryPath =
|
|
46134
|
+
const registryPath = import_path15.default.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
46050
46135
|
try {
|
|
46051
46136
|
const { farmRegistry } = await import(
|
|
46052
46137
|
/* @vite-ignore */
|
|
@@ -46063,7 +46148,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
46063
46148
|
}
|
|
46064
46149
|
farmRegistry.routePaths = routePaths;
|
|
46065
46150
|
try {
|
|
46066
|
-
const clientManifestPath =
|
|
46151
|
+
const clientManifestPath = import_path15.default.join(root, distDir, "client", "farm-client-manifest.json");
|
|
46067
46152
|
const { readFile: readFile7 } = await import("fs/promises");
|
|
46068
46153
|
const manifestContent = await readFile7(clientManifestPath, "utf-8");
|
|
46069
46154
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|
|
@@ -47373,14 +47458,14 @@ var _SPARouter = class _SPARouter {
|
|
|
47373
47458
|
/**
|
|
47374
47459
|
* Fetch page data from cache or server
|
|
47375
47460
|
*/
|
|
47376
|
-
async fetchPageData(
|
|
47377
|
-
const cacheKey = getPageDataCacheKey(
|
|
47461
|
+
async fetchPageData(path38, recover = true, interceptFrom, fresh = false) {
|
|
47462
|
+
const cacheKey = getPageDataCacheKey(path38, interceptFrom);
|
|
47378
47463
|
const cached = fresh ? void 0 : this.cache.get(cacheKey);
|
|
47379
47464
|
if (cached && Date.now() - cached.timestamp < this.options.cacheMaxAge) {
|
|
47380
47465
|
return cached.data;
|
|
47381
47466
|
}
|
|
47382
47467
|
const activeLayoutChain = getActiveLayoutChainHeader();
|
|
47383
|
-
const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(
|
|
47468
|
+
const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(path38)}`, {
|
|
47384
47469
|
headers: createFarmDeploymentRequestHeaders(this.options.deploymentId, {
|
|
47385
47470
|
Accept: "application/x-farm-deferred+json, application/json",
|
|
47386
47471
|
"X-Farm-SPA": "1",
|
|
@@ -47395,7 +47480,7 @@ var _SPARouter = class _SPARouter {
|
|
|
47395
47480
|
);
|
|
47396
47481
|
dispatchDeploymentMismatch(error);
|
|
47397
47482
|
if (recover) {
|
|
47398
|
-
window.location.assign(
|
|
47483
|
+
window.location.assign(path38);
|
|
47399
47484
|
}
|
|
47400
47485
|
throw error;
|
|
47401
47486
|
}
|
|
@@ -47414,16 +47499,16 @@ var _SPARouter = class _SPARouter {
|
|
|
47414
47499
|
*/
|
|
47415
47500
|
async handlePopState(event) {
|
|
47416
47501
|
if (document.documentElement.dataset.farmDocsRuntime === "true") return;
|
|
47417
|
-
const
|
|
47502
|
+
const path38 = window.location.pathname + window.location.search;
|
|
47418
47503
|
if (await this.shouldBlockNavigation({
|
|
47419
|
-
from: event.state?.path ||
|
|
47420
|
-
to:
|
|
47504
|
+
from: event.state?.path || path38,
|
|
47505
|
+
to: path38,
|
|
47421
47506
|
action: "pop"
|
|
47422
47507
|
})) {
|
|
47423
47508
|
return;
|
|
47424
47509
|
}
|
|
47425
47510
|
this.startNavigation({
|
|
47426
|
-
from: event.state?.path ||
|
|
47511
|
+
from: event.state?.path || path38,
|
|
47427
47512
|
to: createNavigationLocation(new URL(window.location.href)),
|
|
47428
47513
|
action: "pop"
|
|
47429
47514
|
});
|
|
@@ -47435,7 +47520,7 @@ var _SPARouter = class _SPARouter {
|
|
|
47435
47520
|
action: "pop"
|
|
47436
47521
|
});
|
|
47437
47522
|
const interceptFrom = typeof event.state?.[FARM_INTERCEPT_FROM_KEY] === "string" ? event.state[FARM_INTERCEPT_FROM_KEY] : void 0;
|
|
47438
|
-
const pageData = await this.fetchPageData(
|
|
47523
|
+
const pageData = await this.fetchPageData(path38, true, interceptFrom);
|
|
47439
47524
|
if (clientNavigation) {
|
|
47440
47525
|
await this.clientPlugins?.markNavigationLoaded(clientNavigation, pageData);
|
|
47441
47526
|
}
|
|
@@ -47466,8 +47551,8 @@ var _SPARouter = class _SPARouter {
|
|
|
47466
47551
|
/**
|
|
47467
47552
|
* Check if URL is cached
|
|
47468
47553
|
*/
|
|
47469
|
-
isCached(
|
|
47470
|
-
const cached = this.cache.get(getPageDataCacheKey(
|
|
47554
|
+
isCached(path38, interceptFrom) {
|
|
47555
|
+
const cached = this.cache.get(getPageDataCacheKey(path38, interceptFrom));
|
|
47471
47556
|
return cached !== void 0 && Date.now() - cached.timestamp < this.options.cacheMaxAge;
|
|
47472
47557
|
}
|
|
47473
47558
|
/**
|
|
@@ -47521,15 +47606,15 @@ var _SPARouter = class _SPARouter {
|
|
|
47521
47606
|
/**
|
|
47522
47607
|
* Save scroll position for a path
|
|
47523
47608
|
*/
|
|
47524
|
-
saveScrollPosition(
|
|
47609
|
+
saveScrollPosition(path38) {
|
|
47525
47610
|
try {
|
|
47526
47611
|
sessionStorage.setItem(
|
|
47527
|
-
`farm-scroll-${
|
|
47612
|
+
`farm-scroll-${path38}`,
|
|
47528
47613
|
JSON.stringify({ x: window.scrollX, y: window.scrollY })
|
|
47529
47614
|
);
|
|
47530
47615
|
for (const [key, element] of this.scrollElements) {
|
|
47531
47616
|
sessionStorage.setItem(
|
|
47532
|
-
getScrollElementStorageKey(
|
|
47617
|
+
getScrollElementStorageKey(path38, key),
|
|
47533
47618
|
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop })
|
|
47534
47619
|
);
|
|
47535
47620
|
}
|
|
@@ -47539,22 +47624,22 @@ var _SPARouter = class _SPARouter {
|
|
|
47539
47624
|
/**
|
|
47540
47625
|
* Restore scroll position for a path
|
|
47541
47626
|
*/
|
|
47542
|
-
restoreScrollPosition(
|
|
47627
|
+
restoreScrollPosition(path38) {
|
|
47543
47628
|
try {
|
|
47544
|
-
const saved = sessionStorage.getItem(`farm-scroll-${
|
|
47629
|
+
const saved = sessionStorage.getItem(`farm-scroll-${path38}`);
|
|
47545
47630
|
if (saved) {
|
|
47546
47631
|
const { x, y } = JSON.parse(saved);
|
|
47547
47632
|
setTimeout(() => window.scrollTo(x, y), 0);
|
|
47548
47633
|
}
|
|
47549
47634
|
for (const [key, element] of this.scrollElements) {
|
|
47550
|
-
this.restoreScrollElement(
|
|
47635
|
+
this.restoreScrollElement(path38, key, element);
|
|
47551
47636
|
}
|
|
47552
47637
|
} catch {
|
|
47553
47638
|
}
|
|
47554
47639
|
}
|
|
47555
|
-
restoreScrollElement(
|
|
47640
|
+
restoreScrollElement(path38, key, element) {
|
|
47556
47641
|
try {
|
|
47557
|
-
const saved = sessionStorage.getItem(getScrollElementStorageKey(
|
|
47642
|
+
const saved = sessionStorage.getItem(getScrollElementStorageKey(path38, key));
|
|
47558
47643
|
if (!saved) return;
|
|
47559
47644
|
const { x, y } = JSON.parse(saved);
|
|
47560
47645
|
setTimeout(() => {
|
|
@@ -47623,11 +47708,11 @@ function readPageState() {
|
|
|
47623
47708
|
return state[FARM_PAGE_STATE_KEY] ?? null;
|
|
47624
47709
|
}
|
|
47625
47710
|
__name(readPageState, "readPageState");
|
|
47626
|
-
function createHistoryState(
|
|
47711
|
+
function createHistoryState(path38, pageState, currentState, interceptFrom) {
|
|
47627
47712
|
const base = currentState && typeof currentState === "object" ? { ...currentState } : {};
|
|
47628
47713
|
const nextState = {
|
|
47629
47714
|
...base,
|
|
47630
|
-
path:
|
|
47715
|
+
path: path38,
|
|
47631
47716
|
[FARM_PAGE_STATE_KEY]: pageState
|
|
47632
47717
|
};
|
|
47633
47718
|
if (interceptFrom === null) {
|
|
@@ -47638,9 +47723,9 @@ function createHistoryState(path37, pageState, currentState, interceptFrom) {
|
|
|
47638
47723
|
return nextState;
|
|
47639
47724
|
}
|
|
47640
47725
|
__name(createHistoryState, "createHistoryState");
|
|
47641
|
-
function getPageDataCacheKey(
|
|
47642
|
-
return interceptFrom ? `${
|
|
47643
|
-
intercept:${interceptFrom}` :
|
|
47726
|
+
function getPageDataCacheKey(path38, interceptFrom) {
|
|
47727
|
+
return interceptFrom ? `${path38}
|
|
47728
|
+
intercept:${interceptFrom}` : path38;
|
|
47644
47729
|
}
|
|
47645
47730
|
__name(getPageDataCacheKey, "getPageDataCacheKey");
|
|
47646
47731
|
function createNavigationLocation(url) {
|
|
@@ -47652,8 +47737,8 @@ function createNavigationLocation(url) {
|
|
|
47652
47737
|
};
|
|
47653
47738
|
}
|
|
47654
47739
|
__name(createNavigationLocation, "createNavigationLocation");
|
|
47655
|
-
function getScrollElementStorageKey(
|
|
47656
|
-
return `farm-scroll-${
|
|
47740
|
+
function getScrollElementStorageKey(path38, key) {
|
|
47741
|
+
return `farm-scroll-${path38}:${key}`;
|
|
47657
47742
|
}
|
|
47658
47743
|
__name(getScrollElementStorageKey, "getScrollElementStorageKey");
|
|
47659
47744
|
|
|
@@ -48414,10 +48499,10 @@ var _DefaultFarmRuntimeErrorOverlay = class _DefaultFarmRuntimeErrorOverlay {
|
|
|
48414
48499
|
container.replaceChildren();
|
|
48415
48500
|
const source = this.document.createElement("div");
|
|
48416
48501
|
source.className = "farm-default-error__source";
|
|
48417
|
-
const
|
|
48418
|
-
|
|
48419
|
-
|
|
48420
|
-
source.appendChild(
|
|
48502
|
+
const path38 = this.document.createElement("p");
|
|
48503
|
+
path38.className = "farm-default-error__source-path";
|
|
48504
|
+
path38.textContent = formatSourcePath(sourceFrame);
|
|
48505
|
+
source.appendChild(path38);
|
|
48421
48506
|
const pre = this.document.createElement("pre");
|
|
48422
48507
|
pre.className = "farm-default-error__source-code";
|
|
48423
48508
|
pre.tabIndex = 0;
|
|
@@ -48646,7 +48731,7 @@ function normalizeSourceLine(value) {
|
|
|
48646
48731
|
return value.trim().replace(/\s+/g, " ");
|
|
48647
48732
|
}
|
|
48648
48733
|
__name(normalizeSourceLine, "normalizeSourceLine");
|
|
48649
|
-
function createSourceFrame2(source,
|
|
48734
|
+
function createSourceFrame2(source, path38, line, column) {
|
|
48650
48735
|
const lines = source.split(/\r?\n/);
|
|
48651
48736
|
if (line < 1 || line > lines.length) return void 0;
|
|
48652
48737
|
const start = Math.max(1, line - 2);
|
|
@@ -48659,7 +48744,7 @@ function createSourceFrame2(source, path37, line, column) {
|
|
|
48659
48744
|
highlight: number === line
|
|
48660
48745
|
});
|
|
48661
48746
|
}
|
|
48662
|
-
return { path:
|
|
48747
|
+
return { path: path38, line, column, lines: frameLines };
|
|
48663
48748
|
}
|
|
48664
48749
|
__name(createSourceFrame2, "createSourceFrame");
|
|
48665
48750
|
function formatDisplaySourceUrl(url, clientWindow) {
|