@farm.js/core 0.1.0-beta.23 → 0.1.0-beta.24
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/{app-DA6ospIq.d.mts → app-DrFCUMHY.d.mts} +1 -0
- package/dist/{app-CTFnOJaI.d.ts → app-pwvKG2B1.d.ts} +1 -0
- package/dist/{chunk-TX54PXAJ.mjs → chunk-HVJHNKSP.mjs} +141 -40
- package/dist/chunk-HVJHNKSP.mjs.map +1 -0
- package/dist/{chunk-FJGTYLCO.mjs → chunk-HXE4VGH2.mjs} +14 -2
- package/dist/chunk-HXE4VGH2.mjs.map +1 -0
- package/dist/{chunk-5NOVWCFL.mjs → chunk-WO466YX5.mjs} +2 -2
- package/dist/{chunk-5NOVWCFL.mjs.map → chunk-WO466YX5.mjs.map} +1 -1
- package/dist/index.cjs +480 -360
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/internal/build-runtime.cjs +384 -264
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/plugin.cjs +242 -141
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/server.cjs +250 -149
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +244 -143
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-FJGTYLCO.mjs.map +0 -1
- package/dist/chunk-TX54PXAJ.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -148,8 +148,8 @@ function toViteModuleId(filePath, root) {
|
|
|
148
148
|
}
|
|
149
149
|
async function fileExists(filePath) {
|
|
150
150
|
try {
|
|
151
|
-
const
|
|
152
|
-
await
|
|
151
|
+
const fs10 = await import("fs/promises");
|
|
152
|
+
await fs10.access(filePath);
|
|
153
153
|
return true;
|
|
154
154
|
} catch {
|
|
155
155
|
return false;
|
|
@@ -673,13 +673,13 @@ function defineIntegrationAPI(api3) {
|
|
|
673
673
|
}
|
|
674
674
|
function operation(method, pathOrOptions, maybeOptions = {}) {
|
|
675
675
|
const hasExplicitPath = typeof pathOrOptions === "string";
|
|
676
|
-
const
|
|
676
|
+
const path33 = hasExplicitPath ? pathOrOptions : "";
|
|
677
677
|
const options = hasExplicitPath ? maybeOptions : {
|
|
678
678
|
...maybeOptions,
|
|
679
679
|
...pathOrOptions
|
|
680
680
|
};
|
|
681
681
|
return defineIntegrationAPIOperation({
|
|
682
|
-
path:
|
|
682
|
+
path: path33,
|
|
683
683
|
method,
|
|
684
684
|
__pathless: !hasExplicitPath,
|
|
685
685
|
...options
|
|
@@ -691,26 +691,26 @@ function get(pathOrOptions, maybeOptions = {}) {
|
|
|
691
691
|
function isOperation(value) {
|
|
692
692
|
return !!value && typeof value === "object" && value.kind === "farm-integration-api-operation";
|
|
693
693
|
}
|
|
694
|
-
function bindRoutePath(
|
|
694
|
+
function bindRoutePath(path33, api3) {
|
|
695
695
|
const entries = Object.entries(api3).map(([key, value]) => {
|
|
696
696
|
if (isOperation(value)) {
|
|
697
697
|
return [
|
|
698
698
|
key,
|
|
699
699
|
{
|
|
700
700
|
...value,
|
|
701
|
-
path:
|
|
701
|
+
path: path33,
|
|
702
702
|
__pathless: false
|
|
703
703
|
}
|
|
704
704
|
];
|
|
705
705
|
}
|
|
706
706
|
if (value && typeof value === "object") {
|
|
707
|
-
return [key, bindRoutePath(
|
|
707
|
+
return [key, bindRoutePath(path33, value)];
|
|
708
708
|
}
|
|
709
709
|
return [key, value];
|
|
710
710
|
});
|
|
711
711
|
return Object.fromEntries(entries);
|
|
712
712
|
}
|
|
713
|
-
function route(
|
|
713
|
+
function route(path33, definitionOrOperation, ...operations) {
|
|
714
714
|
if (isOperation(definitionOrOperation)) {
|
|
715
715
|
const allOperations = [definitionOrOperation, ...operations];
|
|
716
716
|
return Object.fromEntries(
|
|
@@ -718,13 +718,13 @@ function route(path32, definitionOrOperation, ...operations) {
|
|
|
718
718
|
operation2.method.toLowerCase(),
|
|
719
719
|
{
|
|
720
720
|
...operation2,
|
|
721
|
-
path:
|
|
721
|
+
path: path33,
|
|
722
722
|
__pathless: false
|
|
723
723
|
}
|
|
724
724
|
])
|
|
725
725
|
);
|
|
726
726
|
}
|
|
727
|
-
return bindRoutePath(
|
|
727
|
+
return bindRoutePath(path33, definitionOrOperation);
|
|
728
728
|
}
|
|
729
729
|
function normalizeRouteSegment(segment) {
|
|
730
730
|
if (!segment) {
|
|
@@ -745,8 +745,8 @@ function normalizeRouteSegment(segment) {
|
|
|
745
745
|
function camelCaseRouteSegment(segment) {
|
|
746
746
|
return segment.replace(/-([a-zA-Z0-9])/g, (_match, value) => value.toUpperCase());
|
|
747
747
|
}
|
|
748
|
-
function getRouteClientSegments(
|
|
749
|
-
const segments =
|
|
748
|
+
function getRouteClientSegments(path33) {
|
|
749
|
+
const segments = path33.split("/").filter(Boolean);
|
|
750
750
|
if (segments.length === 0) {
|
|
751
751
|
return ["index"];
|
|
752
752
|
}
|
|
@@ -1113,11 +1113,11 @@ function resolveFarmServerHealthConfig(config) {
|
|
|
1113
1113
|
return Object.freeze({ enabled: true, livenessPath, readinessPath });
|
|
1114
1114
|
}
|
|
1115
1115
|
function normalizeHealthPath(value, optionName) {
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
1116
|
+
const path33 = value.trim();
|
|
1117
|
+
if (!path33.startsWith("/") || path33.includes("?") || path33.includes("#") || path33.includes("*")) {
|
|
1118
1118
|
throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
|
|
1119
1119
|
}
|
|
1120
|
-
return
|
|
1120
|
+
return path33.length > 1 ? path33.replace(/\/+$/, "") || "/" : path33;
|
|
1121
1121
|
}
|
|
1122
1122
|
function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
|
|
1123
1123
|
if (typeof value === "number") {
|
|
@@ -1214,7 +1214,7 @@ async function readNodeRequestBody(request, limit) {
|
|
|
1214
1214
|
request.resume?.();
|
|
1215
1215
|
throw error;
|
|
1216
1216
|
}
|
|
1217
|
-
return await new Promise((
|
|
1217
|
+
return await new Promise((resolve7, reject) => {
|
|
1218
1218
|
const chunks = [];
|
|
1219
1219
|
let total = 0;
|
|
1220
1220
|
let settled = false;
|
|
@@ -1243,7 +1243,7 @@ async function readNodeRequestBody(request, limit) {
|
|
|
1243
1243
|
if (settled) return;
|
|
1244
1244
|
settled = true;
|
|
1245
1245
|
cleanup();
|
|
1246
|
-
|
|
1246
|
+
resolve7(Buffer.concat(chunks, total));
|
|
1247
1247
|
}, "onEnd");
|
|
1248
1248
|
const onError = /* @__PURE__ */ __name((error) => rejectOnce(error), "onError");
|
|
1249
1249
|
request.on("data", onData);
|
|
@@ -1458,9 +1458,9 @@ function getFarmIntegrationPluginOwner(plugin) {
|
|
|
1458
1458
|
const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
|
|
1459
1459
|
return value && typeof value === "object" ? value : void 0;
|
|
1460
1460
|
}
|
|
1461
|
-
function defineTypedIntegrationRoute(method,
|
|
1461
|
+
function defineTypedIntegrationRoute(method, path33, input) {
|
|
1462
1462
|
return {
|
|
1463
|
-
path:
|
|
1463
|
+
path: path33,
|
|
1464
1464
|
method,
|
|
1465
1465
|
middleware: input.middleware,
|
|
1466
1466
|
before: input.before,
|
|
@@ -1470,7 +1470,7 @@ function defineTypedIntegrationRoute(method, path32, input) {
|
|
|
1470
1470
|
input: normalizeIntegrationRouteInputSchemas(input),
|
|
1471
1471
|
handler: input.handler,
|
|
1472
1472
|
__operation: defineIntegrationAPIOperation({
|
|
1473
|
-
path:
|
|
1473
|
+
path: path33,
|
|
1474
1474
|
method,
|
|
1475
1475
|
bodyFormat: input.bodyFormat,
|
|
1476
1476
|
responseFormat: input.responseFormat,
|
|
@@ -1482,52 +1482,52 @@ function defineTypedIntegrationRoute(method, path32, input) {
|
|
|
1482
1482
|
}
|
|
1483
1483
|
function createIntegrationRouteFactory() {
|
|
1484
1484
|
return {
|
|
1485
|
-
get(
|
|
1485
|
+
get(path33, input) {
|
|
1486
1486
|
return defineTypedIntegrationRoute(
|
|
1487
1487
|
"GET",
|
|
1488
|
-
|
|
1488
|
+
path33,
|
|
1489
1489
|
input
|
|
1490
1490
|
);
|
|
1491
1491
|
},
|
|
1492
|
-
post(
|
|
1492
|
+
post(path33, input) {
|
|
1493
1493
|
return defineTypedIntegrationRoute(
|
|
1494
1494
|
"POST",
|
|
1495
|
-
|
|
1495
|
+
path33,
|
|
1496
1496
|
{
|
|
1497
1497
|
bodyFormat: "json",
|
|
1498
1498
|
...input
|
|
1499
1499
|
}
|
|
1500
1500
|
);
|
|
1501
1501
|
},
|
|
1502
|
-
put(
|
|
1502
|
+
put(path33, input) {
|
|
1503
1503
|
return defineTypedIntegrationRoute(
|
|
1504
1504
|
"PUT",
|
|
1505
|
-
|
|
1505
|
+
path33,
|
|
1506
1506
|
{
|
|
1507
1507
|
bodyFormat: "json",
|
|
1508
1508
|
...input
|
|
1509
1509
|
}
|
|
1510
1510
|
);
|
|
1511
1511
|
},
|
|
1512
|
-
patch(
|
|
1513
|
-
return defineTypedIntegrationRoute("PATCH",
|
|
1512
|
+
patch(path33, input) {
|
|
1513
|
+
return defineTypedIntegrationRoute("PATCH", path33, {
|
|
1514
1514
|
bodyFormat: "json",
|
|
1515
1515
|
...input
|
|
1516
1516
|
});
|
|
1517
1517
|
},
|
|
1518
|
-
delete(
|
|
1519
|
-
return defineTypedIntegrationRoute("DELETE",
|
|
1518
|
+
delete(path33, input) {
|
|
1519
|
+
return defineTypedIntegrationRoute("DELETE", path33, {
|
|
1520
1520
|
bodyFormat: "json",
|
|
1521
1521
|
...input
|
|
1522
1522
|
});
|
|
1523
1523
|
},
|
|
1524
|
-
options(
|
|
1525
|
-
return defineTypedIntegrationRoute("OPTIONS",
|
|
1524
|
+
options(path33, input) {
|
|
1525
|
+
return defineTypedIntegrationRoute("OPTIONS", path33, input);
|
|
1526
1526
|
},
|
|
1527
|
-
head(
|
|
1527
|
+
head(path33, input) {
|
|
1528
1528
|
return defineTypedIntegrationRoute(
|
|
1529
1529
|
"HEAD",
|
|
1530
|
-
|
|
1530
|
+
path33,
|
|
1531
1531
|
input
|
|
1532
1532
|
);
|
|
1533
1533
|
}
|
|
@@ -1874,8 +1874,8 @@ async function parseIntegrationConfigSchema(integration, schema, value) {
|
|
|
1874
1874
|
function createIntegrationConfigValidationError(integration, error) {
|
|
1875
1875
|
const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
|
|
1876
1876
|
const normalizedPath = normalizeIntegrationValidationPath(issue.path);
|
|
1877
|
-
const
|
|
1878
|
-
return `${
|
|
1877
|
+
const path33 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
|
|
1878
|
+
return `${path33}${issue.message || "Invalid config"}`;
|
|
1879
1879
|
}).join("; ") : error.message || "Invalid config";
|
|
1880
1880
|
return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
|
|
1881
1881
|
}
|
|
@@ -2572,8 +2572,8 @@ function normalizeIntegrationValidationIssues(source, error) {
|
|
|
2572
2572
|
}
|
|
2573
2573
|
];
|
|
2574
2574
|
}
|
|
2575
|
-
function normalizeIntegrationValidationPath(
|
|
2576
|
-
return (
|
|
2575
|
+
function normalizeIntegrationValidationPath(path33) {
|
|
2576
|
+
return (path33 || []).map((segment) => {
|
|
2577
2577
|
const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
|
|
2578
2578
|
return typeof key === "symbol" ? key.description || key.toString() : key;
|
|
2579
2579
|
});
|
|
@@ -4008,22 +4008,22 @@ async function prepareFarmWorkflowsForNitro(config) {
|
|
|
4008
4008
|
}
|
|
4009
4009
|
const root = config.root || process.cwd();
|
|
4010
4010
|
const distDir = config.distDir || ".farm";
|
|
4011
|
-
const
|
|
4012
|
-
const
|
|
4013
|
-
const generatedDir =
|
|
4014
|
-
await
|
|
4011
|
+
const fs10 = await import("fs/promises");
|
|
4012
|
+
const path33 = await import("path");
|
|
4013
|
+
const generatedDir = path33.join(root, distDir, ".nitro", "farm-workflows");
|
|
4014
|
+
await fs10.mkdir(generatedDir, { recursive: true });
|
|
4015
4015
|
const tasks = {};
|
|
4016
4016
|
const scheduledTasks = createScheduledTasks(workflows);
|
|
4017
4017
|
for (const workflow of workflows) {
|
|
4018
|
-
const wrapperPath =
|
|
4019
|
-
await
|
|
4018
|
+
const wrapperPath = path33.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
|
|
4019
|
+
await fs10.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
|
|
4020
4020
|
tasks[workflow.id] = {
|
|
4021
4021
|
handler: wrapperPath,
|
|
4022
4022
|
description: workflow.description || `Farm workflow ${workflow.id}`
|
|
4023
4023
|
};
|
|
4024
4024
|
}
|
|
4025
|
-
const handlerPath =
|
|
4026
|
-
await
|
|
4025
|
+
const handlerPath = path33.join(generatedDir, "http-handler.mjs");
|
|
4026
|
+
await fs10.writeFile(
|
|
4027
4027
|
handlerPath,
|
|
4028
4028
|
createNitroWorkflowHTTPHandler(
|
|
4029
4029
|
workflowConfig,
|
|
@@ -4032,8 +4032,8 @@ async function prepareFarmWorkflowsForNitro(config) {
|
|
|
4032
4032
|
),
|
|
4033
4033
|
"utf8"
|
|
4034
4034
|
);
|
|
4035
|
-
const manifestPath =
|
|
4036
|
-
await
|
|
4035
|
+
const manifestPath = path33.join(generatedDir, "manifest.json");
|
|
4036
|
+
await fs10.writeFile(
|
|
4037
4037
|
manifestPath,
|
|
4038
4038
|
JSON.stringify(
|
|
4039
4039
|
{
|
|
@@ -4114,22 +4114,22 @@ function resolveWorkflowDefinition(module2) {
|
|
|
4114
4114
|
return null;
|
|
4115
4115
|
}
|
|
4116
4116
|
async function findWorkflowFiles(root, dirs) {
|
|
4117
|
-
const
|
|
4118
|
-
const
|
|
4117
|
+
const fs10 = await import("fs/promises");
|
|
4118
|
+
const path33 = await import("path");
|
|
4119
4119
|
const files = [];
|
|
4120
4120
|
for (const dir of dirs) {
|
|
4121
|
-
const absoluteDir =
|
|
4121
|
+
const absoluteDir = path33.isAbsolute(dir) ? dir : path33.join(root, dir);
|
|
4122
4122
|
if (!await pathExists(absoluteDir)) continue;
|
|
4123
4123
|
await walkWorkflowDir(absoluteDir, files);
|
|
4124
4124
|
}
|
|
4125
4125
|
return files.sort();
|
|
4126
4126
|
}
|
|
4127
4127
|
async function walkWorkflowDir(dir, files) {
|
|
4128
|
-
const
|
|
4129
|
-
const
|
|
4130
|
-
const entries = await
|
|
4128
|
+
const fs10 = await import("fs/promises");
|
|
4129
|
+
const path33 = await import("path");
|
|
4130
|
+
const entries = await fs10.readdir(dir, { withFileTypes: true });
|
|
4131
4131
|
for (const entry of entries) {
|
|
4132
|
-
const filePath =
|
|
4132
|
+
const filePath = path33.join(dir, entry.name);
|
|
4133
4133
|
if (entry.isDirectory()) {
|
|
4134
4134
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
4135
4135
|
await walkWorkflowDir(filePath, files);
|
|
@@ -4141,20 +4141,20 @@ async function walkWorkflowDir(dir, files) {
|
|
|
4141
4141
|
}
|
|
4142
4142
|
}
|
|
4143
4143
|
async function pathExists(filePath) {
|
|
4144
|
-
const
|
|
4145
|
-
return
|
|
4144
|
+
const fs10 = await import("fs/promises");
|
|
4145
|
+
return fs10.access(filePath).then(() => true).catch(() => false);
|
|
4146
4146
|
}
|
|
4147
4147
|
function isWorkflowFile(fileName) {
|
|
4148
4148
|
return /\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(fileName) && !/\.d\.[cm]?ts$/.test(fileName);
|
|
4149
4149
|
}
|
|
4150
4150
|
async function loadWorkflowModule(filePath, root) {
|
|
4151
|
-
const
|
|
4152
|
-
const
|
|
4151
|
+
const fs10 = await import("fs/promises");
|
|
4152
|
+
const path33 = await import("path");
|
|
4153
4153
|
const { pathToFileURL: pathToFileURL5 } = await import("url");
|
|
4154
4154
|
const { build: build2 } = await import("esbuild");
|
|
4155
|
-
const outDir =
|
|
4156
|
-
await
|
|
4157
|
-
const outfile =
|
|
4155
|
+
const outDir = path33.join(root, ".farm", ".workflow-loader");
|
|
4156
|
+
await fs10.mkdir(outDir, { recursive: true });
|
|
4157
|
+
const outfile = path33.join(
|
|
4158
4158
|
outDir,
|
|
4159
4159
|
`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
|
|
4160
4160
|
);
|
|
@@ -4178,7 +4178,7 @@ async function loadWorkflowModule(filePath, root) {
|
|
|
4178
4178
|
`${pathToFileURL5(outfile).href}?t=${Date.now()}`
|
|
4179
4179
|
);
|
|
4180
4180
|
} finally {
|
|
4181
|
-
await
|
|
4181
|
+
await fs10.unlink(outfile).catch(() => void 0);
|
|
4182
4182
|
}
|
|
4183
4183
|
}
|
|
4184
4184
|
function workflowIdFromFile(root, filePath) {
|
|
@@ -4448,14 +4448,14 @@ async function prepareFarmCronForNitro(config) {
|
|
|
4448
4448
|
const cron = isResolvedCronConfig(config.cron) ? config.cron : resolveCronConfig(config.cron);
|
|
4449
4449
|
const root = config.root || process.cwd();
|
|
4450
4450
|
const distDir = config.distDir || ".farm";
|
|
4451
|
-
const
|
|
4452
|
-
const
|
|
4453
|
-
const manifestPath =
|
|
4454
|
-
const generatedDir =
|
|
4451
|
+
const fs10 = await import("fs/promises");
|
|
4452
|
+
const path33 = await import("path");
|
|
4453
|
+
const manifestPath = path33.join(root, distDir, FARM_CRON_MANIFEST);
|
|
4454
|
+
const generatedDir = path33.join(root, distDir, ".nitro", "farm-cron");
|
|
4455
4455
|
if (!cron.enabled) {
|
|
4456
4456
|
await Promise.all([
|
|
4457
|
-
|
|
4458
|
-
|
|
4457
|
+
fs10.rm(manifestPath, { force: true }),
|
|
4458
|
+
fs10.rm(generatedDir, { recursive: true, force: true })
|
|
4459
4459
|
]);
|
|
4460
4460
|
return {
|
|
4461
4461
|
jobs: [],
|
|
@@ -4463,21 +4463,21 @@ async function prepareFarmCronForNitro(config) {
|
|
|
4463
4463
|
scheduledTasks: {}
|
|
4464
4464
|
};
|
|
4465
4465
|
}
|
|
4466
|
-
await
|
|
4467
|
-
await
|
|
4466
|
+
await fs10.rm(generatedDir, { recursive: true, force: true });
|
|
4467
|
+
await fs10.mkdir(generatedDir, { recursive: true });
|
|
4468
4468
|
const tasks = {};
|
|
4469
4469
|
for (const job of cron.jobs) {
|
|
4470
4470
|
const taskName = getFarmCronTaskName(job.name);
|
|
4471
|
-
const wrapperPath =
|
|
4472
|
-
await
|
|
4471
|
+
const wrapperPath = path33.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
|
|
4472
|
+
await fs10.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
|
|
4473
4473
|
tasks[taskName] = {
|
|
4474
4474
|
handler: wrapperPath,
|
|
4475
4475
|
description: job.description || `Farm cron ${job.name}`
|
|
4476
4476
|
};
|
|
4477
4477
|
}
|
|
4478
4478
|
const manifest = createFarmCronManifest(cron);
|
|
4479
|
-
await
|
|
4480
|
-
await
|
|
4479
|
+
await fs10.mkdir(path33.dirname(manifestPath), { recursive: true });
|
|
4480
|
+
await fs10.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
4481
4481
|
`, "utf8");
|
|
4482
4482
|
return {
|
|
4483
4483
|
jobs: cron.jobs,
|
|
@@ -4578,7 +4578,7 @@ function normalizeCronJob(name, job) {
|
|
|
4578
4578
|
if (!job || typeof job !== "object" || Array.isArray(job)) {
|
|
4579
4579
|
throw new TypeError(`Farm cron ${JSON.stringify(name)} must be a configuration object.`);
|
|
4580
4580
|
}
|
|
4581
|
-
const
|
|
4581
|
+
const path33 = normalizeCronPath(name, job.path);
|
|
4582
4582
|
const rawSchedule = Array.isArray(job.schedule) ? job.schedule : [job.schedule];
|
|
4583
4583
|
const schedule = [...new Set(rawSchedule.map((value) => normalizeCronExpression(name, value)))];
|
|
4584
4584
|
if (schedule.length === 0) {
|
|
@@ -4587,7 +4587,7 @@ function normalizeCronJob(name, job) {
|
|
|
4587
4587
|
return {
|
|
4588
4588
|
name,
|
|
4589
4589
|
schedule,
|
|
4590
|
-
path:
|
|
4590
|
+
path: path33,
|
|
4591
4591
|
description: job.description?.trim() || void 0
|
|
4592
4592
|
};
|
|
4593
4593
|
}
|
|
@@ -4595,13 +4595,13 @@ function normalizeCronPath(name, value) {
|
|
|
4595
4595
|
if (typeof value !== "string" || !value.trim().startsWith("/")) {
|
|
4596
4596
|
throw new TypeError(`Farm cron ${JSON.stringify(name)} path must start with "/".`);
|
|
4597
4597
|
}
|
|
4598
|
-
const
|
|
4599
|
-
if (
|
|
4598
|
+
const path33 = value.trim();
|
|
4599
|
+
if (path33.startsWith("//") || path33.includes("?") || path33.includes("#")) {
|
|
4600
4600
|
throw new TypeError(
|
|
4601
4601
|
`Farm cron ${JSON.stringify(name)} path must be an application pathname without a host, query, or hash.`
|
|
4602
4602
|
);
|
|
4603
4603
|
}
|
|
4604
|
-
return
|
|
4604
|
+
return path33.length > 1 ? path33.replace(/\/+$/, "") : path33;
|
|
4605
4605
|
}
|
|
4606
4606
|
function normalizeCronExpression(name, value) {
|
|
4607
4607
|
if (typeof value !== "string") {
|
|
@@ -5733,7 +5733,7 @@ var init_server_action_security = __esm({
|
|
|
5733
5733
|
|
|
5734
5734
|
// src/image-config.ts
|
|
5735
5735
|
function resolveFarmImageConfig(config) {
|
|
5736
|
-
const
|
|
5736
|
+
const path33 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
|
|
5737
5737
|
const deviceSizes = normalizeIntegerList(
|
|
5738
5738
|
config?.deviceSizes ?? DEFAULT_FARM_IMAGE_DEVICE_SIZES,
|
|
5739
5739
|
"images.deviceSizes"
|
|
@@ -5761,7 +5761,7 @@ function resolveFarmImageConfig(config) {
|
|
|
5761
5761
|
);
|
|
5762
5762
|
return Object.freeze({
|
|
5763
5763
|
provider: config?.provider ?? "auto",
|
|
5764
|
-
path:
|
|
5764
|
+
path: path33,
|
|
5765
5765
|
domains: Object.freeze([
|
|
5766
5766
|
...new Set(
|
|
5767
5767
|
(config?.domains ?? []).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
|
|
@@ -5800,11 +5800,11 @@ function getPublicFarmImageConfig(config) {
|
|
|
5800
5800
|
};
|
|
5801
5801
|
}
|
|
5802
5802
|
function normalizeImagePath(value) {
|
|
5803
|
-
const
|
|
5804
|
-
if (!
|
|
5803
|
+
const path33 = value.trim().replace(/\/+$/, "") || "/";
|
|
5804
|
+
if (!path33.startsWith("/") || path33.includes("?") || path33.includes("#")) {
|
|
5805
5805
|
throw new TypeError("images.path must be an absolute pathname without a query or hash");
|
|
5806
5806
|
}
|
|
5807
|
-
return
|
|
5807
|
+
return path33;
|
|
5808
5808
|
}
|
|
5809
5809
|
function normalizeIntegerList(values, name, max) {
|
|
5810
5810
|
if (values.length === 0) {
|
|
@@ -7208,7 +7208,7 @@ function normalizePositiveDuration(value, fallback, name) {
|
|
|
7208
7208
|
return Math.floor(value);
|
|
7209
7209
|
}
|
|
7210
7210
|
function delay(ms) {
|
|
7211
|
-
return new Promise((
|
|
7211
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
7212
7212
|
}
|
|
7213
7213
|
function normalizeCacheOptionsTags(options) {
|
|
7214
7214
|
const tags = /* @__PURE__ */ new Set();
|
|
@@ -7792,7 +7792,7 @@ function getProgrammaticRouteSearchClientOptions(search) {
|
|
|
7792
7792
|
if (search.temporary?.length) options.temporary = [...search.temporary];
|
|
7793
7793
|
return Object.keys(options).length > 0 ? options : void 0;
|
|
7794
7794
|
}
|
|
7795
|
-
function resolveProgrammaticRouteSearch(searchConfig, rawSearch,
|
|
7795
|
+
function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path33, routePath) {
|
|
7796
7796
|
const schema = getProgrammaticRouteSearchSchema(searchConfig);
|
|
7797
7797
|
const search = parseProgrammaticSchema(schema, rawSearch, "search", routePath);
|
|
7798
7798
|
const options = getProgrammaticRouteSearchOptions(searchConfig);
|
|
@@ -7801,7 +7801,7 @@ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path32, routePa
|
|
|
7801
7801
|
schema,
|
|
7802
7802
|
rawSearch,
|
|
7803
7803
|
parsedSearch: search,
|
|
7804
|
-
path:
|
|
7804
|
+
path: path33
|
|
7805
7805
|
});
|
|
7806
7806
|
return { search, canonicalPath };
|
|
7807
7807
|
}
|
|
@@ -7880,8 +7880,8 @@ function normalizeComparableValue(value) {
|
|
|
7880
7880
|
}
|
|
7881
7881
|
return value;
|
|
7882
7882
|
}
|
|
7883
|
-
function createRoute(
|
|
7884
|
-
return routesBuilder.page(
|
|
7883
|
+
function createRoute(path33, options) {
|
|
7884
|
+
return routesBuilder.page(path33, options);
|
|
7885
7885
|
}
|
|
7886
7886
|
function isProgrammaticRoutesFileName(fileName) {
|
|
7887
7887
|
const normalized = fileName.replace(/\\/g, "/");
|
|
@@ -7971,7 +7971,7 @@ function createRouteModuleFromProgrammaticPage(route2) {
|
|
|
7971
7971
|
mod.__farmRouteData = route2.data;
|
|
7972
7972
|
mod.__farmRouteParsesProps = true;
|
|
7973
7973
|
mod.__farmResolveRouteProps = (props) => resolveProgrammaticRouteProps(route2, props);
|
|
7974
|
-
mod.__farmResolveRouteCanonicalPath = (rawSearch,
|
|
7974
|
+
mod.__farmResolveRouteCanonicalPath = (rawSearch, path33) => resolveProgrammaticRouteSearch(route2.search, rawSearch, path33, route2.path).canonicalPath;
|
|
7975
7975
|
}
|
|
7976
7976
|
if (route2.pending || route2.error || route2.notFound) {
|
|
7977
7977
|
mod.__farmRouteComponents = {
|
|
@@ -8369,25 +8369,25 @@ var init_routes = __esm({
|
|
|
8369
8369
|
];
|
|
8370
8370
|
__name(defineRoutes, "defineRoutes");
|
|
8371
8371
|
routesBuilder = {
|
|
8372
|
-
page(
|
|
8372
|
+
page(path33, options) {
|
|
8373
8373
|
return normalizeProgrammaticRoute({
|
|
8374
8374
|
kind: "page",
|
|
8375
|
-
path:
|
|
8375
|
+
path: path33,
|
|
8376
8376
|
...options
|
|
8377
8377
|
});
|
|
8378
8378
|
},
|
|
8379
|
-
layout(
|
|
8379
|
+
layout(path33, options) {
|
|
8380
8380
|
return normalizeProgrammaticRoute({
|
|
8381
8381
|
kind: "layout",
|
|
8382
|
-
path:
|
|
8382
|
+
path: path33,
|
|
8383
8383
|
...options
|
|
8384
8384
|
});
|
|
8385
8385
|
},
|
|
8386
|
-
api(
|
|
8386
|
+
api(path33, options) {
|
|
8387
8387
|
const { render, runtime, regions, maxDuration, ...methods } = options;
|
|
8388
8388
|
return normalizeProgrammaticRoute({
|
|
8389
8389
|
kind: "api",
|
|
8390
|
-
path:
|
|
8390
|
+
path: path33,
|
|
8391
8391
|
render,
|
|
8392
8392
|
runtime,
|
|
8393
8393
|
regions,
|
|
@@ -8758,6 +8758,35 @@ function getIslandStrategyExport(content) {
|
|
|
8758
8758
|
function stripUseClientDirective(content) {
|
|
8759
8759
|
return content.replace(/^\s*(["'])use client\1\s*;?\s*/, "");
|
|
8760
8760
|
}
|
|
8761
|
+
function hasAsyncDefaultExport(content) {
|
|
8762
|
+
if (!content) return false;
|
|
8763
|
+
const tokens = tokenizeModuleSource(content);
|
|
8764
|
+
for (let index = 0; index < tokens.length - 2; index++) {
|
|
8765
|
+
const token = tokens[index];
|
|
8766
|
+
if (token.kind !== "identifier" || token.value !== "export") continue;
|
|
8767
|
+
if (tokens[index - 1]?.value === ".") continue;
|
|
8768
|
+
if (tokens[index + 1]?.value !== "default") continue;
|
|
8769
|
+
const exported = tokens[index + 2];
|
|
8770
|
+
if (exported.kind === "identifier" && exported.value === "async") {
|
|
8771
|
+
return true;
|
|
8772
|
+
}
|
|
8773
|
+
if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && tokens[index + 3]?.value !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
|
|
8774
|
+
return true;
|
|
8775
|
+
}
|
|
8776
|
+
}
|
|
8777
|
+
return false;
|
|
8778
|
+
}
|
|
8779
|
+
function isAsyncLocalDeclaration(tokens, name) {
|
|
8780
|
+
for (let index = 0; index < tokens.length - 2; index++) {
|
|
8781
|
+
if (tokens[index].value === "async" && tokens[index + 1]?.value === "function" && tokens[index + 2]?.value === name) {
|
|
8782
|
+
return true;
|
|
8783
|
+
}
|
|
8784
|
+
if (tokens[index].value === name && tokens[index + 1]?.value === "=" && tokens[index + 2]?.value === "async") {
|
|
8785
|
+
return true;
|
|
8786
|
+
}
|
|
8787
|
+
}
|
|
8788
|
+
return false;
|
|
8789
|
+
}
|
|
8761
8790
|
function parseClientModuleMetadata(content, inspectIslandExport) {
|
|
8762
8791
|
if (!content) {
|
|
8763
8792
|
return {
|
|
@@ -8811,6 +8840,14 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
|
|
|
8811
8840
|
}
|
|
8812
8841
|
}
|
|
8813
8842
|
const shouldHydrate = parsed.hasHydrateExport || importsClientBoundary;
|
|
8843
|
+
if (shouldHydrate && hasAsyncDefaultExport(content)) {
|
|
8844
|
+
return {
|
|
8845
|
+
isClientComponent: false,
|
|
8846
|
+
shouldHydrate: false,
|
|
8847
|
+
islandStrategy: null,
|
|
8848
|
+
suppressedAsyncHydration: true
|
|
8849
|
+
};
|
|
8850
|
+
}
|
|
8814
8851
|
return {
|
|
8815
8852
|
isClientComponent: false,
|
|
8816
8853
|
shouldHydrate,
|
|
@@ -9111,6 +9148,8 @@ var init_client_component = __esm({
|
|
|
9111
9148
|
__name(isIslandExportStart, "isIslandExportStart");
|
|
9112
9149
|
__name(getIslandStrategyExport, "getIslandStrategyExport");
|
|
9113
9150
|
__name(stripUseClientDirective, "stripUseClientDirective");
|
|
9151
|
+
__name(hasAsyncDefaultExport, "hasAsyncDefaultExport");
|
|
9152
|
+
__name(isAsyncLocalDeclaration, "isAsyncLocalDeclaration");
|
|
9114
9153
|
__name(parseClientModuleMetadata, "parseClientModuleMetadata");
|
|
9115
9154
|
__name(getClientModuleMetadata, "getClientModuleMetadata");
|
|
9116
9155
|
__name(inspectClientModuleMetadata, "inspectClientModuleMetadata");
|
|
@@ -9671,6 +9710,7 @@ var init_route_manager = __esm({
|
|
|
9671
9710
|
shouldHydrate: metadata.shouldHydrate,
|
|
9672
9711
|
isClientComponent: metadata.isClientComponent,
|
|
9673
9712
|
islandStrategy: metadata.islandStrategy,
|
|
9713
|
+
suppressedAsyncHydration: metadata.suppressedAsyncHydration,
|
|
9674
9714
|
search: getProgrammaticRouteSearchClientOptions(programmaticPage?.search),
|
|
9675
9715
|
segments: entry.route.segments.map((seg) => ({
|
|
9676
9716
|
segment: seg.segment,
|
|
@@ -10424,12 +10464,12 @@ function isFarmRouteActive(pattern, pathname, options = {}) {
|
|
|
10424
10464
|
}
|
|
10425
10465
|
function normalizeRouteInput(input, index) {
|
|
10426
10466
|
const route2 = typeof input === "string" ? { path: input } : input;
|
|
10427
|
-
const
|
|
10428
|
-
const segments = parseRoutePattern(
|
|
10467
|
+
const path33 = normalizePathname2(route2.path);
|
|
10468
|
+
const segments = parseRoutePattern(path33);
|
|
10429
10469
|
return {
|
|
10430
10470
|
route: {
|
|
10431
10471
|
...route2,
|
|
10432
|
-
path:
|
|
10472
|
+
path: path33
|
|
10433
10473
|
},
|
|
10434
10474
|
segments,
|
|
10435
10475
|
score: scoreSegments(segments),
|
|
@@ -10860,8 +10900,8 @@ function getControlledDeferred(id, controllers) {
|
|
|
10860
10900
|
if (existing) return existing;
|
|
10861
10901
|
let nativeResolve;
|
|
10862
10902
|
let nativeReject;
|
|
10863
|
-
const promise = new Promise((
|
|
10864
|
-
nativeResolve =
|
|
10903
|
+
const promise = new Promise((resolve7, reject) => {
|
|
10904
|
+
nativeResolve = resolve7;
|
|
10865
10905
|
nativeReject = reject;
|
|
10866
10906
|
});
|
|
10867
10907
|
promise.status = "pending";
|
|
@@ -11075,8 +11115,8 @@ function createFarmDeploymentMismatchError(response, clientDeploymentId) {
|
|
|
11075
11115
|
getFarmResponseDeploymentId(response) || "unknown"
|
|
11076
11116
|
);
|
|
11077
11117
|
}
|
|
11078
|
-
function createFarmDeploymentCookie(deploymentId,
|
|
11079
|
-
const normalizedPath =
|
|
11118
|
+
function createFarmDeploymentCookie(deploymentId, path33 = "/", secure = false) {
|
|
11119
|
+
const normalizedPath = path33.startsWith("/") ? path33 : `/${path33}`;
|
|
11080
11120
|
return [
|
|
11081
11121
|
`${FARM_DEPLOYMENT_COOKIE}=${encodeURIComponent(deploymentId)}`,
|
|
11082
11122
|
`Path=${normalizedPath}`,
|
|
@@ -11257,11 +11297,11 @@ function readPageState() {
|
|
|
11257
11297
|
if (!state || typeof state !== "object") return null;
|
|
11258
11298
|
return state[FARM_PAGE_STATE_KEY] ?? null;
|
|
11259
11299
|
}
|
|
11260
|
-
function createHistoryState(
|
|
11300
|
+
function createHistoryState(path33, pageState, currentState, interceptFrom) {
|
|
11261
11301
|
const base = currentState && typeof currentState === "object" ? { ...currentState } : {};
|
|
11262
11302
|
const nextState = {
|
|
11263
11303
|
...base,
|
|
11264
|
-
path:
|
|
11304
|
+
path: path33,
|
|
11265
11305
|
[FARM_PAGE_STATE_KEY]: pageState
|
|
11266
11306
|
};
|
|
11267
11307
|
if (interceptFrom === null) {
|
|
@@ -11271,9 +11311,9 @@ function createHistoryState(path32, pageState, currentState, interceptFrom) {
|
|
|
11271
11311
|
}
|
|
11272
11312
|
return nextState;
|
|
11273
11313
|
}
|
|
11274
|
-
function getPageDataCacheKey(
|
|
11275
|
-
return interceptFrom ? `${
|
|
11276
|
-
intercept:${interceptFrom}` :
|
|
11314
|
+
function getPageDataCacheKey(path33, interceptFrom) {
|
|
11315
|
+
return interceptFrom ? `${path33}
|
|
11316
|
+
intercept:${interceptFrom}` : path33;
|
|
11277
11317
|
}
|
|
11278
11318
|
function createNavigationLocation(url) {
|
|
11279
11319
|
return {
|
|
@@ -11283,8 +11323,8 @@ function createNavigationLocation(url) {
|
|
|
11283
11323
|
hash: url.hash
|
|
11284
11324
|
};
|
|
11285
11325
|
}
|
|
11286
|
-
function getScrollElementStorageKey(
|
|
11287
|
-
return `farm-scroll-${
|
|
11326
|
+
function getScrollElementStorageKey(path33, key) {
|
|
11327
|
+
return `farm-scroll-${path33}:${key}`;
|
|
11288
11328
|
}
|
|
11289
11329
|
var FARM_PAGE_STATE_KEY, FARM_INTERCEPT_FROM_KEY, IDLE_NAVIGATION_STATE, routerInstance, _SPARouter, SPARouter;
|
|
11290
11330
|
var init_spa_router = __esm({
|
|
@@ -11570,13 +11610,13 @@ var init_spa_router = __esm({
|
|
|
11570
11610
|
/**
|
|
11571
11611
|
* Fetch page data from cache or server
|
|
11572
11612
|
*/
|
|
11573
|
-
async fetchPageData(
|
|
11574
|
-
const cacheKey = getPageDataCacheKey(
|
|
11613
|
+
async fetchPageData(path33, recover = true, interceptFrom) {
|
|
11614
|
+
const cacheKey = getPageDataCacheKey(path33, interceptFrom);
|
|
11575
11615
|
const cached = this.cache.get(cacheKey);
|
|
11576
11616
|
if (cached && Date.now() - cached.timestamp < this.options.cacheMaxAge) {
|
|
11577
11617
|
return cached.data;
|
|
11578
11618
|
}
|
|
11579
|
-
const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(
|
|
11619
|
+
const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(path33)}`, {
|
|
11580
11620
|
headers: createFarmDeploymentRequestHeaders(this.options.deploymentId, {
|
|
11581
11621
|
Accept: "application/x-farm-deferred+json, application/json",
|
|
11582
11622
|
"X-Farm-SPA": "1",
|
|
@@ -11590,7 +11630,7 @@ var init_spa_router = __esm({
|
|
|
11590
11630
|
);
|
|
11591
11631
|
dispatchDeploymentMismatch(error);
|
|
11592
11632
|
if (recover) {
|
|
11593
|
-
window.location.assign(
|
|
11633
|
+
window.location.assign(path33);
|
|
11594
11634
|
}
|
|
11595
11635
|
throw error;
|
|
11596
11636
|
}
|
|
@@ -11609,16 +11649,16 @@ var init_spa_router = __esm({
|
|
|
11609
11649
|
*/
|
|
11610
11650
|
async handlePopState(event) {
|
|
11611
11651
|
if (document.documentElement.dataset.farmDocsRuntime === "true") return;
|
|
11612
|
-
const
|
|
11652
|
+
const path33 = window.location.pathname + window.location.search;
|
|
11613
11653
|
if (await this.shouldBlockNavigation({
|
|
11614
|
-
from: event.state?.path ||
|
|
11615
|
-
to:
|
|
11654
|
+
from: event.state?.path || path33,
|
|
11655
|
+
to: path33,
|
|
11616
11656
|
action: "pop"
|
|
11617
11657
|
})) {
|
|
11618
11658
|
return;
|
|
11619
11659
|
}
|
|
11620
11660
|
this.startNavigation({
|
|
11621
|
-
from: event.state?.path ||
|
|
11661
|
+
from: event.state?.path || path33,
|
|
11622
11662
|
to: createNavigationLocation(new URL(window.location.href)),
|
|
11623
11663
|
action: "pop"
|
|
11624
11664
|
});
|
|
@@ -11630,7 +11670,7 @@ var init_spa_router = __esm({
|
|
|
11630
11670
|
action: "pop"
|
|
11631
11671
|
});
|
|
11632
11672
|
const interceptFrom = typeof event.state?.[FARM_INTERCEPT_FROM_KEY] === "string" ? event.state[FARM_INTERCEPT_FROM_KEY] : void 0;
|
|
11633
|
-
const pageData = await this.fetchPageData(
|
|
11673
|
+
const pageData = await this.fetchPageData(path33, true, interceptFrom);
|
|
11634
11674
|
if (clientNavigation) {
|
|
11635
11675
|
await this.clientPlugins?.markNavigationLoaded(clientNavigation, pageData);
|
|
11636
11676
|
}
|
|
@@ -11661,8 +11701,8 @@ var init_spa_router = __esm({
|
|
|
11661
11701
|
/**
|
|
11662
11702
|
* Check if URL is cached
|
|
11663
11703
|
*/
|
|
11664
|
-
isCached(
|
|
11665
|
-
const cached = this.cache.get(getPageDataCacheKey(
|
|
11704
|
+
isCached(path33, interceptFrom) {
|
|
11705
|
+
const cached = this.cache.get(getPageDataCacheKey(path33, interceptFrom));
|
|
11666
11706
|
return cached !== void 0 && Date.now() - cached.timestamp < this.options.cacheMaxAge;
|
|
11667
11707
|
}
|
|
11668
11708
|
/**
|
|
@@ -11716,15 +11756,15 @@ var init_spa_router = __esm({
|
|
|
11716
11756
|
/**
|
|
11717
11757
|
* Save scroll position for a path
|
|
11718
11758
|
*/
|
|
11719
|
-
saveScrollPosition(
|
|
11759
|
+
saveScrollPosition(path33) {
|
|
11720
11760
|
try {
|
|
11721
11761
|
sessionStorage.setItem(
|
|
11722
|
-
`farm-scroll-${
|
|
11762
|
+
`farm-scroll-${path33}`,
|
|
11723
11763
|
JSON.stringify({ x: window.scrollX, y: window.scrollY })
|
|
11724
11764
|
);
|
|
11725
11765
|
for (const [key, element] of this.scrollElements) {
|
|
11726
11766
|
sessionStorage.setItem(
|
|
11727
|
-
getScrollElementStorageKey(
|
|
11767
|
+
getScrollElementStorageKey(path33, key),
|
|
11728
11768
|
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop })
|
|
11729
11769
|
);
|
|
11730
11770
|
}
|
|
@@ -11734,22 +11774,22 @@ var init_spa_router = __esm({
|
|
|
11734
11774
|
/**
|
|
11735
11775
|
* Restore scroll position for a path
|
|
11736
11776
|
*/
|
|
11737
|
-
restoreScrollPosition(
|
|
11777
|
+
restoreScrollPosition(path33) {
|
|
11738
11778
|
try {
|
|
11739
|
-
const saved = sessionStorage.getItem(`farm-scroll-${
|
|
11779
|
+
const saved = sessionStorage.getItem(`farm-scroll-${path33}`);
|
|
11740
11780
|
if (saved) {
|
|
11741
11781
|
const { x, y } = JSON.parse(saved);
|
|
11742
11782
|
setTimeout(() => window.scrollTo(x, y), 0);
|
|
11743
11783
|
}
|
|
11744
11784
|
for (const [key, element] of this.scrollElements) {
|
|
11745
|
-
this.restoreScrollElement(
|
|
11785
|
+
this.restoreScrollElement(path33, key, element);
|
|
11746
11786
|
}
|
|
11747
11787
|
} catch {
|
|
11748
11788
|
}
|
|
11749
11789
|
}
|
|
11750
|
-
restoreScrollElement(
|
|
11790
|
+
restoreScrollElement(path33, key, element) {
|
|
11751
11791
|
try {
|
|
11752
|
-
const saved = sessionStorage.getItem(getScrollElementStorageKey(
|
|
11792
|
+
const saved = sessionStorage.getItem(getScrollElementStorageKey(path33, key));
|
|
11753
11793
|
if (!saved) return;
|
|
11754
11794
|
const { x, y } = JSON.parse(saved);
|
|
11755
11795
|
setTimeout(() => {
|
|
@@ -14515,6 +14555,13 @@ var init_server3 = __esm({
|
|
|
14515
14555
|
});
|
|
14516
14556
|
|
|
14517
14557
|
// src/server/renderer.ts
|
|
14558
|
+
function warnSuppressedAsyncHydrationOnce(modulePath) {
|
|
14559
|
+
if (warnedSuppressedAsyncHydrationModules.has(modulePath)) return;
|
|
14560
|
+
warnedSuppressedAsyncHydrationModules.add(modulePath);
|
|
14561
|
+
logger.warn(
|
|
14562
|
+
`${modulePath} is an async server component that imports client components. React cannot hydrate async components in the browser, so this route stays server-rendered and its client imports are not interactive. Move the interactive UI into a "use client" child rendered by a synchronous page, or enable experimental server components support.`
|
|
14563
|
+
);
|
|
14564
|
+
}
|
|
14518
14565
|
function hasRequestHeader(req, name) {
|
|
14519
14566
|
const value = req.headers[name.toLowerCase()];
|
|
14520
14567
|
return Array.isArray(value) ? value.length > 0 : Boolean(value);
|
|
@@ -14669,7 +14716,7 @@ function createRouteStateProps(input) {
|
|
|
14669
14716
|
context: input.pluginExposedContext.size > 0 ? { data: input.pluginExposedContext } : void 0
|
|
14670
14717
|
};
|
|
14671
14718
|
}
|
|
14672
|
-
var import_react5, import_server2, fs2, path9, import_stream, cachedClerkProvider, importRuntimeModule, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
|
|
14719
|
+
var import_react5, import_server2, fs2, path9, import_stream, cachedClerkProvider, importRuntimeModule, warnedSuppressedAsyncHydrationModules, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
|
|
14673
14720
|
var init_renderer = __esm({
|
|
14674
14721
|
"src/server/renderer.ts"() {
|
|
14675
14722
|
"use strict";
|
|
@@ -14703,6 +14750,8 @@ var init_renderer = __esm({
|
|
|
14703
14750
|
init_server3();
|
|
14704
14751
|
cachedClerkProvider = null;
|
|
14705
14752
|
importRuntimeModule = new Function("specifier", "return import(specifier);");
|
|
14753
|
+
warnedSuppressedAsyncHydrationModules = /* @__PURE__ */ new Set();
|
|
14754
|
+
__name(warnSuppressedAsyncHydrationOnce, "warnSuppressedAsyncHydrationOnce");
|
|
14706
14755
|
__name(hasRequestHeader, "hasRequestHeader");
|
|
14707
14756
|
__name(serializeInlineValue2, "serializeInlineValue");
|
|
14708
14757
|
__name(escapeHtmlAttribute2, "escapeHtmlAttribute");
|
|
@@ -15223,6 +15272,9 @@ var init_renderer = __esm({
|
|
|
15223
15272
|
})
|
|
15224
15273
|
);
|
|
15225
15274
|
const shouldHydrate = moduleMetadata.shouldHydrate;
|
|
15275
|
+
if (moduleMetadata.suppressedAsyncHydration) {
|
|
15276
|
+
warnSuppressedAsyncHydrationOnce(route2.modulePath);
|
|
15277
|
+
}
|
|
15226
15278
|
const layoutHydrationMetadata = layouts.map((layout2) => {
|
|
15227
15279
|
const manifestEntry = routeManifest.layouts.find(
|
|
15228
15280
|
(entry) => entry.pattern === layout2.pattern
|
|
@@ -15720,7 +15772,7 @@ var init_renderer = __esm({
|
|
|
15720
15772
|
}
|
|
15721
15773
|
}
|
|
15722
15774
|
async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
|
|
15723
|
-
return new Promise((
|
|
15775
|
+
return new Promise((resolve7, reject) => {
|
|
15724
15776
|
const streamStartTime = Date.now();
|
|
15725
15777
|
const observabilityRoute = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
|
|
15726
15778
|
const deploymentId = this.getDeploymentId();
|
|
@@ -15920,7 +15972,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
15920
15972
|
route: observabilityRoute,
|
|
15921
15973
|
durationMs: Date.now() - streamStartTime
|
|
15922
15974
|
});
|
|
15923
|
-
|
|
15975
|
+
resolve7();
|
|
15924
15976
|
}
|
|
15925
15977
|
});
|
|
15926
15978
|
res.write(shell);
|
|
@@ -17180,15 +17232,15 @@ function isEndpointFailure(value) {
|
|
|
17180
17232
|
return value instanceof EndpointFailure;
|
|
17181
17233
|
}
|
|
17182
17234
|
function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
|
|
17183
|
-
let
|
|
17235
|
+
let path33;
|
|
17184
17236
|
let options;
|
|
17185
17237
|
let handler;
|
|
17186
17238
|
if (typeof pathOrOptions === "string") {
|
|
17187
|
-
|
|
17239
|
+
path33 = pathOrOptions;
|
|
17188
17240
|
options = optionsOrHandler;
|
|
17189
17241
|
handler = maybeHandler;
|
|
17190
17242
|
} else {
|
|
17191
|
-
|
|
17243
|
+
path33 = "";
|
|
17192
17244
|
options = pathOrOptions;
|
|
17193
17245
|
handler = optionsOrHandler;
|
|
17194
17246
|
}
|
|
@@ -17215,13 +17267,13 @@ function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
|
|
|
17215
17267
|
...betterCallOptions
|
|
17216
17268
|
} = options;
|
|
17217
17269
|
const endpoint2 = (0, import_better_call.createEndpoint)(
|
|
17218
|
-
|
|
17270
|
+
path33 || "/__farm_auto_path__",
|
|
17219
17271
|
betterCallOptions,
|
|
17220
17272
|
wrappedHandler
|
|
17221
17273
|
);
|
|
17222
|
-
endpoint2.__path =
|
|
17274
|
+
endpoint2.__path = path33 || void 0;
|
|
17223
17275
|
endpoint2.__method = options.method || "GET";
|
|
17224
|
-
endpoint2.__autoPath = !
|
|
17276
|
+
endpoint2.__autoPath = !path33;
|
|
17225
17277
|
endpoint2.__handler = wrappedHandler;
|
|
17226
17278
|
endpoint2.__farmInvoke = (ctx) => runEndpointMiddleware(middleware2, ctx, handler, error, options.invalidates);
|
|
17227
17279
|
endpoint2.__middleware = middleware2;
|
|
@@ -18932,11 +18984,11 @@ var init_type_generator = __esm({
|
|
|
18932
18984
|
routeGroups.get(key).push(route2);
|
|
18933
18985
|
}
|
|
18934
18986
|
const nestedStructure = {};
|
|
18935
|
-
for (const [
|
|
18987
|
+
for (const [path33, routeList] of routeGroups) {
|
|
18936
18988
|
const route2 = routeList[0];
|
|
18937
18989
|
const importPath = this.getRouteImportPath(route2, options.outFile);
|
|
18938
18990
|
const routeName = this.pathToRouteName(route2.path);
|
|
18939
|
-
const cleanPath =
|
|
18991
|
+
const cleanPath = path33 === "/api" ? "" : path33.replace(/^\/api\//, "");
|
|
18940
18992
|
const parts = cleanPath ? cleanPath.split("/") : [];
|
|
18941
18993
|
const allMethods = routeList.flatMap((r) => r.methods);
|
|
18942
18994
|
for (const method of allMethods) {
|
|
@@ -18995,8 +19047,8 @@ ${typeExports}
|
|
|
18995
19047
|
const relativeImport = (0, import_path7.relative)((0, import_path7.dirname)(outFile), route2.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
18996
19048
|
return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
|
|
18997
19049
|
}
|
|
18998
|
-
pathToRouteName(
|
|
18999
|
-
return (
|
|
19050
|
+
pathToRouteName(path33) {
|
|
19051
|
+
return (path33 === "/api" ? "root" : path33.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
|
|
19000
19052
|
}
|
|
19001
19053
|
structureToTypeString(obj, indent) {
|
|
19002
19054
|
const spaces = " ".repeat(indent);
|
|
@@ -19016,15 +19068,15 @@ ${typeExports}
|
|
|
19016
19068
|
toTypePropertyKey(key) {
|
|
19017
19069
|
return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
|
|
19018
19070
|
}
|
|
19019
|
-
getBaseExportName(
|
|
19020
|
-
const cleanPath =
|
|
19071
|
+
getBaseExportName(path33) {
|
|
19072
|
+
const cleanPath = path33.replace(/^\/api\//, "");
|
|
19021
19073
|
if (cleanPath === "") {
|
|
19022
19074
|
return "api";
|
|
19023
19075
|
}
|
|
19024
19076
|
return cleanPath;
|
|
19025
19077
|
}
|
|
19026
|
-
getExportName(
|
|
19027
|
-
const cleanPath =
|
|
19078
|
+
getExportName(path33, method) {
|
|
19079
|
+
const cleanPath = path33.replace(/^\/api\//, "");
|
|
19028
19080
|
if (cleanPath === "") {
|
|
19029
19081
|
return method.toLowerCase();
|
|
19030
19082
|
}
|
|
@@ -20060,7 +20112,7 @@ var init_environment_vite = __esm({
|
|
|
20060
20112
|
var version;
|
|
20061
20113
|
var init_package = __esm({
|
|
20062
20114
|
"package.json"() {
|
|
20063
|
-
version = "0.1.0-beta.
|
|
20115
|
+
version = "0.1.0-beta.24";
|
|
20064
20116
|
}
|
|
20065
20117
|
});
|
|
20066
20118
|
|
|
@@ -20097,8 +20149,8 @@ function reportAfterError(state, error) {
|
|
|
20097
20149
|
function createAfterRequestState(reportError = defaultAfterErrorReporter) {
|
|
20098
20150
|
let resolveResponseFinished;
|
|
20099
20151
|
let responseFinished = false;
|
|
20100
|
-
const responseFinishedPromise = new Promise((
|
|
20101
|
-
resolveResponseFinished =
|
|
20152
|
+
const responseFinishedPromise = new Promise((resolve7) => {
|
|
20153
|
+
resolveResponseFinished = resolve7;
|
|
20102
20154
|
});
|
|
20103
20155
|
const state = {
|
|
20104
20156
|
completion: Promise.resolve(),
|
|
@@ -20205,8 +20257,8 @@ function after(callback) {
|
|
|
20205
20257
|
throw new Error("after() cannot schedule work after the request lifecycle has completed.");
|
|
20206
20258
|
}
|
|
20207
20259
|
let start;
|
|
20208
|
-
const ready = new Promise((
|
|
20209
|
-
start =
|
|
20260
|
+
const ready = new Promise((resolve7) => {
|
|
20261
|
+
start = resolve7;
|
|
20210
20262
|
});
|
|
20211
20263
|
const result = ready.then(callback);
|
|
20212
20264
|
state.tasks.push({ result, start });
|
|
@@ -20272,6 +20324,40 @@ var init_after = __esm({
|
|
|
20272
20324
|
}
|
|
20273
20325
|
});
|
|
20274
20326
|
|
|
20327
|
+
// src/dev-static.ts
|
|
20328
|
+
function devServableFileExists(pathname, baseDirs) {
|
|
20329
|
+
let decodedPathname;
|
|
20330
|
+
try {
|
|
20331
|
+
decodedPathname = decodeURIComponent(pathname);
|
|
20332
|
+
} catch {
|
|
20333
|
+
return false;
|
|
20334
|
+
}
|
|
20335
|
+
const relativePathname = decodedPathname.replace(/^\/+/, "");
|
|
20336
|
+
if (!relativePathname) return false;
|
|
20337
|
+
for (const baseDir of baseDirs) {
|
|
20338
|
+
if (typeof baseDir !== "string" || baseDir.length === 0) continue;
|
|
20339
|
+
const resolvedBase = path17.resolve(baseDir);
|
|
20340
|
+
const candidate = path17.resolve(resolvedBase, relativePathname);
|
|
20341
|
+
if (!candidate.startsWith(resolvedBase + path17.sep)) continue;
|
|
20342
|
+
try {
|
|
20343
|
+
if (fs7.existsSync(candidate) && fs7.statSync(candidate).isFile()) {
|
|
20344
|
+
return true;
|
|
20345
|
+
}
|
|
20346
|
+
} catch {
|
|
20347
|
+
}
|
|
20348
|
+
}
|
|
20349
|
+
return false;
|
|
20350
|
+
}
|
|
20351
|
+
var fs7, path17;
|
|
20352
|
+
var init_dev_static = __esm({
|
|
20353
|
+
"src/dev-static.ts"() {
|
|
20354
|
+
"use strict";
|
|
20355
|
+
fs7 = __toESM(require("fs"));
|
|
20356
|
+
path17 = __toESM(require("path"));
|
|
20357
|
+
__name(devServableFileExists, "devServableFileExists");
|
|
20358
|
+
}
|
|
20359
|
+
});
|
|
20360
|
+
|
|
20275
20361
|
// src/image-vite.ts
|
|
20276
20362
|
function farmImageImportsPlugin() {
|
|
20277
20363
|
return {
|
|
@@ -24761,37 +24847,37 @@ function sanitizeDocsConfig(config) {
|
|
|
24761
24847
|
return cloneSerializable(config) || {};
|
|
24762
24848
|
}
|
|
24763
24849
|
async function findDocsConfigPath(rootDir, configPath) {
|
|
24764
|
-
const { existsSync:
|
|
24850
|
+
const { existsSync: existsSync18 } = await import("fs");
|
|
24765
24851
|
const root = import_path9.default.resolve(rootDir || process.cwd());
|
|
24766
24852
|
if (configPath) {
|
|
24767
24853
|
const resolvedPath = import_path9.default.isAbsolute(configPath) ? configPath : import_path9.default.join(root, configPath);
|
|
24768
|
-
if (!
|
|
24854
|
+
if (!existsSync18(resolvedPath)) {
|
|
24769
24855
|
throw new Error(`Could not find docs config at ${configPath}.`);
|
|
24770
24856
|
}
|
|
24771
24857
|
return import_path9.default.resolve(resolvedPath);
|
|
24772
24858
|
}
|
|
24773
24859
|
for (const filename of DOCS_CONFIG_FILENAMES) {
|
|
24774
24860
|
const resolvedPath = import_path9.default.join(root, filename);
|
|
24775
|
-
if (
|
|
24861
|
+
if (existsSync18(resolvedPath)) {
|
|
24776
24862
|
return resolvedPath;
|
|
24777
24863
|
}
|
|
24778
24864
|
}
|
|
24779
24865
|
return void 0;
|
|
24780
24866
|
}
|
|
24781
24867
|
async function loadDocsConfig(rootDir, configPath) {
|
|
24782
|
-
const
|
|
24868
|
+
const fs10 = await import("fs/promises");
|
|
24783
24869
|
const { pathToFileURL: pathToFileURL5 } = await import("url");
|
|
24784
24870
|
const root = import_path9.default.resolve(rootDir || process.cwd());
|
|
24785
24871
|
const resolvedPath = await findDocsConfigPath(root, configPath);
|
|
24786
24872
|
if (!resolvedPath) return void 0;
|
|
24787
24873
|
try {
|
|
24788
24874
|
if (resolvedPath.endsWith(".json")) {
|
|
24789
|
-
const content = await
|
|
24875
|
+
const content = await fs10.readFile(resolvedPath, "utf8");
|
|
24790
24876
|
return { config: JSON.parse(content), configPath: resolvedPath };
|
|
24791
24877
|
}
|
|
24792
24878
|
const { build: build2 } = await import("esbuild");
|
|
24793
24879
|
const configCacheDir = import_path9.default.join(root, ".farm", ".config-loader");
|
|
24794
|
-
await
|
|
24880
|
+
await fs10.mkdir(configCacheDir, { recursive: true });
|
|
24795
24881
|
const modulePath = import_path9.default.join(
|
|
24796
24882
|
configCacheDir,
|
|
24797
24883
|
`docs-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
|
|
@@ -24817,7 +24903,7 @@ async function loadDocsConfig(rootDir, configPath) {
|
|
|
24817
24903
|
moduleUrl
|
|
24818
24904
|
);
|
|
24819
24905
|
} finally {
|
|
24820
|
-
await
|
|
24906
|
+
await fs10.unlink(modulePath).catch(() => void 0);
|
|
24821
24907
|
}
|
|
24822
24908
|
return {
|
|
24823
24909
|
config: importedConfig.default || importedConfig,
|
|
@@ -25008,7 +25094,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
25008
25094
|
return resolved;
|
|
25009
25095
|
}
|
|
25010
25096
|
async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "production" ? "production" : "development", loadEnvironment) {
|
|
25011
|
-
const { existsSync:
|
|
25097
|
+
const { existsSync: existsSync18 } = await import("fs");
|
|
25012
25098
|
const loadEnv = loadEnvironment || (await import("vite")).loadEnv;
|
|
25013
25099
|
const root = rootDir || process.cwd();
|
|
25014
25100
|
const loadedEnv = loadEnv(mode, root, "");
|
|
@@ -25032,7 +25118,7 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
|
|
|
25032
25118
|
try {
|
|
25033
25119
|
const absolutePath = relativePath2.startsWith("/") ? relativePath2 : import_path9.default.join(root, relativePath2);
|
|
25034
25120
|
const normalizedPath = import_path9.default.resolve(absolutePath);
|
|
25035
|
-
if (!
|
|
25121
|
+
if (!existsSync18(normalizedPath)) {
|
|
25036
25122
|
continue;
|
|
25037
25123
|
}
|
|
25038
25124
|
const loadedConfig = await loadFarmConfigFile(normalizedPath, { root });
|
|
@@ -25865,8 +25951,8 @@ var init_generator = __esm({
|
|
|
25865
25951
|
}
|
|
25866
25952
|
routeGroups.get(key).push(route2);
|
|
25867
25953
|
}
|
|
25868
|
-
for (const [
|
|
25869
|
-
const openAPIPath = this.convertToOpenAPIPath(
|
|
25954
|
+
for (const [path33, routeList] of routeGroups) {
|
|
25955
|
+
const openAPIPath = this.convertToOpenAPIPath(path33);
|
|
25870
25956
|
spec.paths[openAPIPath] = {};
|
|
25871
25957
|
for (const route2 of routeList) {
|
|
25872
25958
|
for (const method of route2.methods) {
|
|
@@ -25880,8 +25966,8 @@ var init_generator = __esm({
|
|
|
25880
25966
|
/**
|
|
25881
25967
|
* Convert Farm.js API path to OpenAPI path format
|
|
25882
25968
|
*/
|
|
25883
|
-
convertToOpenAPIPath(
|
|
25884
|
-
return
|
|
25969
|
+
convertToOpenAPIPath(path33) {
|
|
25970
|
+
return path33.replace(/^\/api/, "");
|
|
25885
25971
|
}
|
|
25886
25972
|
/**
|
|
25887
25973
|
* Extract request body schema from endpoint
|
|
@@ -26043,8 +26129,8 @@ var init_generator = __esm({
|
|
|
26043
26129
|
/**
|
|
26044
26130
|
* Generate operation summary
|
|
26045
26131
|
*/
|
|
26046
|
-
generateSummary(
|
|
26047
|
-
const cleanPath =
|
|
26132
|
+
generateSummary(path33, method) {
|
|
26133
|
+
const cleanPath = path33.replace(/^\/api\//, "");
|
|
26048
26134
|
const pathParts = cleanPath.split("/");
|
|
26049
26135
|
const lastPart = pathParts[pathParts.length - 1];
|
|
26050
26136
|
const action = method === "GET" ? "Get" : method === "POST" ? "Create" : method === "PUT" ? "Update" : method === "DELETE" ? "Delete" : method === "PATCH" ? "Update" : method;
|
|
@@ -26053,22 +26139,22 @@ var init_generator = __esm({
|
|
|
26053
26139
|
/**
|
|
26054
26140
|
* Generate operation description
|
|
26055
26141
|
*/
|
|
26056
|
-
generateDescription(
|
|
26057
|
-
const cleanPath =
|
|
26142
|
+
generateDescription(path33, method) {
|
|
26143
|
+
const cleanPath = path33.replace(/^\/api\//, "");
|
|
26058
26144
|
return `${method} ${cleanPath} endpoint`;
|
|
26059
26145
|
}
|
|
26060
26146
|
/**
|
|
26061
26147
|
* Generate operation ID
|
|
26062
26148
|
*/
|
|
26063
|
-
generateOperationId(
|
|
26064
|
-
const cleanPath =
|
|
26149
|
+
generateOperationId(path33, method) {
|
|
26150
|
+
const cleanPath = path33.replace(/^\/api\//, "").replace(/\//g, "_");
|
|
26065
26151
|
return `${method.toLowerCase()}_${cleanPath}`;
|
|
26066
26152
|
}
|
|
26067
26153
|
/**
|
|
26068
26154
|
* Generate tags for grouping operations
|
|
26069
26155
|
*/
|
|
26070
|
-
generateTags(
|
|
26071
|
-
const cleanPath =
|
|
26156
|
+
generateTags(path33) {
|
|
26157
|
+
const cleanPath = path33.replace(/^\/api\//, "");
|
|
26072
26158
|
const pathParts = cleanPath.split("/");
|
|
26073
26159
|
if (pathParts.length > 1) {
|
|
26074
26160
|
return [pathParts[0]];
|
|
@@ -26080,13 +26166,13 @@ var init_generator = __esm({
|
|
|
26080
26166
|
*/
|
|
26081
26167
|
async generateSpecFile(routes, outputPath) {
|
|
26082
26168
|
const spec = await this.generateSpec(routes);
|
|
26083
|
-
const
|
|
26084
|
-
const
|
|
26085
|
-
const dir =
|
|
26086
|
-
if (!
|
|
26087
|
-
|
|
26169
|
+
const fs10 = require("fs");
|
|
26170
|
+
const path33 = require("path");
|
|
26171
|
+
const dir = path33.dirname(outputPath);
|
|
26172
|
+
if (!fs10.existsSync(dir)) {
|
|
26173
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
26088
26174
|
}
|
|
26089
|
-
|
|
26175
|
+
fs10.writeFileSync(outputPath, JSON.stringify(spec, null, 2));
|
|
26090
26176
|
}
|
|
26091
26177
|
};
|
|
26092
26178
|
__name(_OpenAPIGenerator, "OpenAPIGenerator");
|
|
@@ -28374,18 +28460,18 @@ function isPotentialProgrammaticRouteSourceFile(normalizedFile, srcDirSlug) {
|
|
|
28374
28460
|
return normalizedFile.startsWith(`${srcDirSlug}/`) && /\.(ts|tsx|js|jsx)$/.test(normalizedFile) && !normalizedFile.endsWith(".d.ts") && !normalizedFile.endsWith("/farm-routes.d.ts") && !normalizedFile.endsWith("/farm-env.d.ts") && !normalizedFile.endsWith("/lib/api.generated.ts");
|
|
28375
28461
|
}
|
|
28376
28462
|
function fileContainsProgrammaticPageRoute(file) {
|
|
28377
|
-
if (!
|
|
28463
|
+
if (!fs8.existsSync(file)) {
|
|
28378
28464
|
return false;
|
|
28379
28465
|
}
|
|
28380
28466
|
try {
|
|
28381
|
-
return scanProgrammaticPagePaths(
|
|
28467
|
+
return scanProgrammaticPagePaths(fs8.readFileSync(file, "utf8")).length > 0;
|
|
28382
28468
|
} catch {
|
|
28383
28469
|
return false;
|
|
28384
28470
|
}
|
|
28385
28471
|
}
|
|
28386
28472
|
function rewriteEarlySsrRelativeImports(options) {
|
|
28387
28473
|
const cleanId = options.id.split("?", 1)[0];
|
|
28388
|
-
if (!
|
|
28474
|
+
if (!path26.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
|
|
28389
28475
|
return null;
|
|
28390
28476
|
}
|
|
28391
28477
|
const replacements = [];
|
|
@@ -28405,7 +28491,7 @@ function rewriteEarlySsrRelativeImports(options) {
|
|
|
28405
28491
|
const suffixIndex = source.value.search(/[?#]/);
|
|
28406
28492
|
const sourcePath = suffixIndex === -1 ? source.value : source.value.slice(0, suffixIndex);
|
|
28407
28493
|
const suffix = suffixIndex === -1 ? "" : source.value.slice(suffixIndex);
|
|
28408
|
-
const resolvedPath =
|
|
28494
|
+
const resolvedPath = path26.resolve(path26.dirname(cleanId), sourcePath);
|
|
28409
28495
|
replacements.push({
|
|
28410
28496
|
start: source.start,
|
|
28411
28497
|
end: source.end,
|
|
@@ -28480,7 +28566,7 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28480
28566
|
...layerRoots.length ? {
|
|
28481
28567
|
server: {
|
|
28482
28568
|
fs: {
|
|
28483
|
-
allow: [
|
|
28569
|
+
allow: [path26.resolve(options.root || process.cwd()), ...layerRoots]
|
|
28484
28570
|
}
|
|
28485
28571
|
}
|
|
28486
28572
|
} : {}
|
|
@@ -28511,13 +28597,13 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28511
28597
|
},
|
|
28512
28598
|
server
|
|
28513
28599
|
);
|
|
28514
|
-
const globalsCSSPath =
|
|
28515
|
-
if (!
|
|
28516
|
-
const appDir =
|
|
28517
|
-
if (!
|
|
28518
|
-
|
|
28600
|
+
const globalsCSSPath = path26.join(server.config.root, "src/app/globals.css");
|
|
28601
|
+
if (!fs8.existsSync(globalsCSSPath)) {
|
|
28602
|
+
const appDir = path26.join(server.config.root, "src/app");
|
|
28603
|
+
if (!fs8.existsSync(appDir)) {
|
|
28604
|
+
fs8.mkdirSync(appDir, { recursive: true });
|
|
28519
28605
|
}
|
|
28520
|
-
|
|
28606
|
+
fs8.writeFileSync(globalsCSSPath, defaultGlobalCSS);
|
|
28521
28607
|
}
|
|
28522
28608
|
await farmApp.initialize();
|
|
28523
28609
|
const farmConfig = farmApp.getConfig();
|
|
@@ -28536,10 +28622,10 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28536
28622
|
});
|
|
28537
28623
|
}
|
|
28538
28624
|
const sourceRoots = getFarmSourceRoots(farmConfig);
|
|
28539
|
-
server.watcher.add(sourceRoots.map((source) =>
|
|
28625
|
+
server.watcher.add(sourceRoots.map((source) => path26.join(source.root, source.srcDir)));
|
|
28540
28626
|
if (farmConfig.i18n.enabled) {
|
|
28541
28627
|
server.watcher.add(
|
|
28542
|
-
farmConfig.i18n.messages.includes("{locale}") ?
|
|
28628
|
+
farmConfig.i18n.messages.includes("{locale}") ? path26.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
|
|
28543
28629
|
);
|
|
28544
28630
|
}
|
|
28545
28631
|
const workflowConfig = farmConfig.workflows;
|
|
@@ -28549,7 +28635,7 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28549
28635
|
...farmDocsDevRuntime?.getFarmDocsRouteTypeEntries(farmConfig.docs) ?? []
|
|
28550
28636
|
], "getExtraRouteTypes");
|
|
28551
28637
|
const appDirSlugs = sourceRoots.map(
|
|
28552
|
-
(source) =>
|
|
28638
|
+
(source) => path26.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
|
|
28553
28639
|
);
|
|
28554
28640
|
const generateTypeArtifacts = /* @__PURE__ */ __name(async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
|
|
28555
28641
|
try {
|
|
@@ -28589,7 +28675,7 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28589
28675
|
}, "generateTypeArtifacts");
|
|
28590
28676
|
await generateTypeArtifacts("startup");
|
|
28591
28677
|
const srcDirSlugs = sourceRoots.map(
|
|
28592
|
-
(source) =>
|
|
28678
|
+
(source) => path26.join(source.root, source.srcDir).replace(/\\/g, "/")
|
|
28593
28679
|
);
|
|
28594
28680
|
const layerConfigFiles = new Set(
|
|
28595
28681
|
farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
|
|
@@ -28707,7 +28793,7 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
28707
28793
|
await apiRouteManager.discoverRoutes();
|
|
28708
28794
|
let discoveredWorkflows = [];
|
|
28709
28795
|
const hasWorkflowDirectory = workflowConfig.enabled && workflowConfig.dirs.some(
|
|
28710
|
-
(dir) =>
|
|
28796
|
+
(dir) => fs8.existsSync(path26.isAbsolute(dir) ? dir : path26.join(farmConfig.root, dir))
|
|
28711
28797
|
);
|
|
28712
28798
|
if (hasWorkflowDirectory) {
|
|
28713
28799
|
const { createFarmWorkflowRequestHandler: createFarmWorkflowRequestHandler2, discoverFarmWorkflows: discoverFarmWorkflows2 } = await loadFarmWorkflowsDevRuntime();
|
|
@@ -28941,12 +29027,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
28941
29027
|
}
|
|
28942
29028
|
}
|
|
28943
29029
|
const farmDocsFontPath = farmDocsFontAssets.get(requestPathname);
|
|
28944
|
-
if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath &&
|
|
29030
|
+
if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs8.existsSync(farmDocsFontPath)) {
|
|
28945
29031
|
res.statusCode = 200;
|
|
28946
29032
|
res.setHeader("Content-Type", "font/woff2");
|
|
28947
29033
|
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
|
28948
29034
|
if (requestMethod === "HEAD") res.end();
|
|
28949
|
-
else
|
|
29035
|
+
else fs8.createReadStream(farmDocsFontPath).pipe(res);
|
|
28950
29036
|
return;
|
|
28951
29037
|
}
|
|
28952
29038
|
if (requestMethod === "GET" && (requestPathname === FARM_DEVTOOLS_PATH || requestPathname === `${FARM_DEVTOOLS_PATH}.json`)) {
|
|
@@ -29044,7 +29130,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
29044
29130
|
return null;
|
|
29045
29131
|
}
|
|
29046
29132
|
return {
|
|
29047
|
-
source: await
|
|
29133
|
+
source: await fs8.promises.readFile(sourcePath, "utf8"),
|
|
29048
29134
|
filePath: sourcePath
|
|
29049
29135
|
};
|
|
29050
29136
|
}, "resolveSource")
|
|
@@ -29379,9 +29465,17 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
29379
29465
|
res.end(JSON.stringify({ error: "API route not found", pathname: pathname2 }));
|
|
29380
29466
|
return;
|
|
29381
29467
|
}
|
|
29382
|
-
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")
|
|
29468
|
+
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
|
|
29383
29469
|
return next();
|
|
29384
29470
|
}
|
|
29471
|
+
if (requestPathname.includes(".") && !requestPathname.endsWith(".html")) {
|
|
29472
|
+
const matchesAppRoute = Boolean(
|
|
29473
|
+
farmApp?.getRouteManager()?.matchRoute(requestPathname)?.route
|
|
29474
|
+
);
|
|
29475
|
+
if (!matchesAppRoute || devServableFileExists(requestPathname, [server.config.publicDir, server.config.root])) {
|
|
29476
|
+
return next();
|
|
29477
|
+
}
|
|
29478
|
+
}
|
|
29385
29479
|
if (req.url?.startsWith("/__farm/page-data")) {
|
|
29386
29480
|
const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
|
|
29387
29481
|
const targetPath = urlObj.searchParams.get("path") || "/";
|
|
@@ -30087,8 +30181,8 @@ if (import.meta.hot) {
|
|
|
30087
30181
|
}
|
|
30088
30182
|
logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
|
|
30089
30183
|
logger.info("Pre-rendering SSG pages...");
|
|
30090
|
-
const outDir =
|
|
30091
|
-
const clientDir =
|
|
30184
|
+
const outDir = path26.join(server?.config.root || process.cwd(), options.outDir || "dist");
|
|
30185
|
+
const clientDir = path26.join(outDir, "client");
|
|
30092
30186
|
for (const page2 of ssgPages) {
|
|
30093
30187
|
try {
|
|
30094
30188
|
const staticRequest = new Request(new URL(page2.urlPath, "http://farm.static"));
|
|
@@ -30140,9 +30234,9 @@ if (import.meta.hot) {
|
|
|
30140
30234
|
<script type="module" src="/assets/client.js"></script>
|
|
30141
30235
|
</body>
|
|
30142
30236
|
</html>`;
|
|
30143
|
-
const outputPath = page2.urlPath === "/" ?
|
|
30144
|
-
|
|
30145
|
-
|
|
30237
|
+
const outputPath = page2.urlPath === "/" ? path26.join(clientDir, "index.html") : path26.join(clientDir, page2.urlPath + ".html");
|
|
30238
|
+
fs8.mkdirSync(path26.dirname(outputPath), { recursive: true });
|
|
30239
|
+
fs8.writeFileSync(outputPath, fullHtml);
|
|
30146
30240
|
const revalidateInfo = page2.revalidate ? ` (revalidate: ${page2.revalidate}s)` : "";
|
|
30147
30241
|
logger.success(` \u2713 ${page2.urlPath}${revalidateInfo}`);
|
|
30148
30242
|
});
|
|
@@ -30150,8 +30244,8 @@ if (import.meta.hot) {
|
|
|
30150
30244
|
logger.error(` \u2717 ${page2.urlPath}: ${error}`);
|
|
30151
30245
|
}
|
|
30152
30246
|
}
|
|
30153
|
-
const manifestPath =
|
|
30154
|
-
|
|
30247
|
+
const manifestPath = path26.join(outDir, "__ssg_manifest.json");
|
|
30248
|
+
fs8.writeFileSync(
|
|
30155
30249
|
manifestPath,
|
|
30156
30250
|
JSON.stringify(
|
|
30157
30251
|
ssgPages.map((p) => ({
|
|
@@ -30186,9 +30280,9 @@ if (import.meta.hot) {
|
|
|
30186
30280
|
}
|
|
30187
30281
|
const currentFarmConfig = farmApp?.getConfig();
|
|
30188
30282
|
const normalizedFile = file.replace(/\\/g, "/");
|
|
30189
|
-
const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) =>
|
|
30283
|
+
const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path26.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
|
|
30190
30284
|
if (currentSrcRoot && normalizedFile.startsWith(`${currentSrcRoot}/`) && isProgrammaticRoutesFileName(normalizedFile)) {
|
|
30191
|
-
logUpdate("PAGE", `updated ${
|
|
30285
|
+
logUpdate("PAGE", `updated ${path26.basename(file)}`);
|
|
30192
30286
|
for (const mod of modules) {
|
|
30193
30287
|
server2.moduleGraph.invalidateModule(mod);
|
|
30194
30288
|
}
|
|
@@ -31368,6 +31462,19 @@ async function tryHydrateImportedPage(
|
|
|
31368
31462
|
const PageComponent = pageModule?.default;
|
|
31369
31463
|
if (!PageComponent) return false;
|
|
31370
31464
|
|
|
31465
|
+
if (
|
|
31466
|
+
typeof PageComponent === 'function' &&
|
|
31467
|
+
PageComponent.constructor &&
|
|
31468
|
+
PageComponent.constructor.name === 'AsyncFunction'
|
|
31469
|
+
) {
|
|
31470
|
+
console.warn(
|
|
31471
|
+
'[Farm.js] Skipping hydration for ' + modulePath +
|
|
31472
|
+
': async server components cannot run in the browser. ' +
|
|
31473
|
+
'Server-rendered HTML is preserved; move interactive UI into a "use client" child of a synchronous page.'
|
|
31474
|
+
);
|
|
31475
|
+
return false;
|
|
31476
|
+
}
|
|
31477
|
+
|
|
31371
31478
|
currentPageComponent = PageComponent;
|
|
31372
31479
|
currentPageProps = await buildRouteComponentProps(
|
|
31373
31480
|
pageModule,
|
|
@@ -31918,7 +32025,7 @@ function generateClientManifest(bundle) {
|
|
|
31918
32025
|
}
|
|
31919
32026
|
async function defineConfig2(config = {}) {
|
|
31920
32027
|
const tailwindcss = (await import("@tailwindcss/vite")).default;
|
|
31921
|
-
const appRoot =
|
|
32028
|
+
const appRoot = path26.resolve(config.root || process.cwd());
|
|
31922
32029
|
if (config.extends?.length) {
|
|
31923
32030
|
const { config: layeredConfig } = await Promise.resolve().then(() => (init_layers(), layers_exports)).then(
|
|
31924
32031
|
({ resolveFarmLayers: resolveFarmLayers2 }) => resolveFarmLayers2(config, {
|
|
@@ -32125,7 +32232,7 @@ async function defineConfig2(config = {}) {
|
|
|
32125
32232
|
}
|
|
32126
32233
|
};
|
|
32127
32234
|
}
|
|
32128
|
-
var
|
|
32235
|
+
var fs8, path26, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
|
|
32129
32236
|
var init_vite2 = __esm({
|
|
32130
32237
|
"src/vite.ts"() {
|
|
32131
32238
|
"use strict";
|
|
@@ -32144,13 +32251,14 @@ var init_vite2 = __esm({
|
|
|
32144
32251
|
init_integrations();
|
|
32145
32252
|
init_route_context();
|
|
32146
32253
|
init_devtools_config();
|
|
32147
|
-
|
|
32148
|
-
|
|
32254
|
+
fs8 = __toESM(require("fs"));
|
|
32255
|
+
path26 = __toESM(require("path"));
|
|
32149
32256
|
init_layers();
|
|
32150
32257
|
init_environment_vite();
|
|
32151
32258
|
init_version();
|
|
32152
32259
|
init_deferred();
|
|
32153
32260
|
init_after();
|
|
32261
|
+
init_dev_static();
|
|
32154
32262
|
init_deployment();
|
|
32155
32263
|
init_image_config();
|
|
32156
32264
|
init_image_vite();
|
|
@@ -35275,8 +35383,8 @@ function createAPIClient(options = {}) {
|
|
|
35275
35383
|
const inflightState = /* @__PURE__ */ new Map();
|
|
35276
35384
|
const routeMeta = /* @__PURE__ */ new WeakMap();
|
|
35277
35385
|
let requestCounter = 0;
|
|
35278
|
-
const fetchClient = /* @__PURE__ */ __name(async (
|
|
35279
|
-
const url = new URL(
|
|
35386
|
+
const fetchClient = /* @__PURE__ */ __name(async (path33, requestOptions = {}) => {
|
|
35387
|
+
const url = new URL(path33, baseURL);
|
|
35280
35388
|
if (requestOptions.query) {
|
|
35281
35389
|
Object.entries(requestOptions.query).forEach(([key, value]) => {
|
|
35282
35390
|
if (value !== void 0 && value !== null) {
|
|
@@ -35311,7 +35419,7 @@ function createAPIClient(options = {}) {
|
|
|
35311
35419
|
}
|
|
35312
35420
|
return { response, data };
|
|
35313
35421
|
}, "fetchClient");
|
|
35314
|
-
const request = /* @__PURE__ */ __name(async (
|
|
35422
|
+
const request = /* @__PURE__ */ __name(async (path33, method, input = {}, clientOptions) => {
|
|
35315
35423
|
const methodUpper = method.toUpperCase();
|
|
35316
35424
|
const requestId = `${Date.now()}-${++requestCounter}`;
|
|
35317
35425
|
const cacheOptions = clientOptions?.cache ? {
|
|
@@ -35320,7 +35428,7 @@ function createAPIClient(options = {}) {
|
|
|
35320
35428
|
} : void 0;
|
|
35321
35429
|
const configuredCacheKey = clientOptions?.key ?? cacheOptions?.key;
|
|
35322
35430
|
const cacheKey = normalizeFarmClientCacheKey(
|
|
35323
|
-
configuredCacheKey ?? buildCacheKey(methodUpper,
|
|
35431
|
+
configuredCacheKey ?? buildCacheKey(methodUpper, path33, input, baseURL)
|
|
35324
35432
|
);
|
|
35325
35433
|
const now2 = Date.now();
|
|
35326
35434
|
const emitStatus = /* @__PURE__ */ __name((phase, payload) => {
|
|
@@ -35402,13 +35510,13 @@ function createAPIClient(options = {}) {
|
|
|
35402
35510
|
requestId,
|
|
35403
35511
|
method: methodUpper,
|
|
35404
35512
|
key: cacheKey,
|
|
35405
|
-
path:
|
|
35513
|
+
path: path33,
|
|
35406
35514
|
input,
|
|
35407
35515
|
attempt,
|
|
35408
35516
|
timestamp: Date.now()
|
|
35409
35517
|
});
|
|
35410
35518
|
try {
|
|
35411
|
-
const { response, data } = await fetchClient(
|
|
35519
|
+
const { response, data } = await fetchClient(path33, {
|
|
35412
35520
|
...input,
|
|
35413
35521
|
method: methodUpper
|
|
35414
35522
|
});
|
|
@@ -35417,7 +35525,7 @@ function createAPIClient(options = {}) {
|
|
|
35417
35525
|
requestId,
|
|
35418
35526
|
method: methodUpper,
|
|
35419
35527
|
key: cacheKey,
|
|
35420
|
-
path:
|
|
35528
|
+
path: path33,
|
|
35421
35529
|
input,
|
|
35422
35530
|
attempt,
|
|
35423
35531
|
timestamp: Date.now(),
|
|
@@ -35440,7 +35548,7 @@ function createAPIClient(options = {}) {
|
|
|
35440
35548
|
requestId,
|
|
35441
35549
|
method: methodUpper,
|
|
35442
35550
|
key: cacheKey,
|
|
35443
|
-
path:
|
|
35551
|
+
path: path33,
|
|
35444
35552
|
input,
|
|
35445
35553
|
attempt,
|
|
35446
35554
|
timestamp: Date.now(),
|
|
@@ -35455,7 +35563,7 @@ function createAPIClient(options = {}) {
|
|
|
35455
35563
|
attempt += 1;
|
|
35456
35564
|
const delay2 = typeof clientOptions?.retry?.delay === "function" ? clientOptions.retry.delay(attempt) : clientOptions?.retry?.delay ?? 0;
|
|
35457
35565
|
if (delay2 > 0) {
|
|
35458
|
-
await new Promise((
|
|
35566
|
+
await new Promise((resolve7) => setTimeout(resolve7, delay2));
|
|
35459
35567
|
}
|
|
35460
35568
|
}
|
|
35461
35569
|
})();
|
|
@@ -35545,17 +35653,17 @@ function createAPIClient(options = {}) {
|
|
|
35545
35653
|
);
|
|
35546
35654
|
}
|
|
35547
35655
|
__name(createAPIClient, "createAPIClient");
|
|
35548
|
-
function createNestedProxy(
|
|
35656
|
+
function createNestedProxy(path33, client, routeMeta, baseURL, sameOrigin, rootAliases) {
|
|
35549
35657
|
const target = /* @__PURE__ */ __name(() => {
|
|
35550
35658
|
}, "target");
|
|
35551
35659
|
const proxy = new Proxy(target, {
|
|
35552
35660
|
// When accessing a property (api.hello)
|
|
35553
35661
|
get(_target, prop) {
|
|
35554
35662
|
if (prop === FARM_API_ROUTE_REF_SYMBOL) {
|
|
35555
|
-
return
|
|
35663
|
+
return path33.length > 0;
|
|
35556
35664
|
}
|
|
35557
35665
|
if (prop === FARM_API_ROUTE_META_SYMBOL) {
|
|
35558
|
-
const metadata = resolveRouteMeta({ path:
|
|
35666
|
+
const metadata = resolveRouteMeta({ path: path33, baseURL });
|
|
35559
35667
|
return Object.freeze({
|
|
35560
35668
|
path: metadata.routePath,
|
|
35561
35669
|
method: metadata.method,
|
|
@@ -35563,14 +35671,14 @@ function createNestedProxy(path32, client, routeMeta, baseURL, sameOrigin, rootA
|
|
|
35563
35671
|
sameOrigin
|
|
35564
35672
|
});
|
|
35565
35673
|
}
|
|
35566
|
-
if (
|
|
35674
|
+
if (path33.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
|
|
35567
35675
|
return rootAliases[prop];
|
|
35568
35676
|
}
|
|
35569
35677
|
if (typeof prop !== "string") {
|
|
35570
35678
|
return Reflect.get(_target, prop);
|
|
35571
35679
|
}
|
|
35572
35680
|
return createNestedProxy(
|
|
35573
|
-
[...
|
|
35681
|
+
[...path33, prop],
|
|
35574
35682
|
client,
|
|
35575
35683
|
routeMeta,
|
|
35576
35684
|
baseURL,
|
|
@@ -35580,21 +35688,21 @@ function createNestedProxy(path32, client, routeMeta, baseURL, sameOrigin, rootA
|
|
|
35580
35688
|
},
|
|
35581
35689
|
// When calling as a function
|
|
35582
35690
|
apply(_target, _thisArg, args) {
|
|
35583
|
-
const lastPart =
|
|
35691
|
+
const lastPart = path33[path33.length - 1];
|
|
35584
35692
|
const httpMethods = ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
35585
35693
|
if (httpMethods.includes(lastPart)) {
|
|
35586
|
-
const routePath = "/api/" +
|
|
35694
|
+
const routePath = "/api/" + path33.slice(0, -1).join("/");
|
|
35587
35695
|
const method = lastPart.toUpperCase();
|
|
35588
35696
|
const [options, clientOptions] = args;
|
|
35589
35697
|
return client(routePath, method, options, clientOptions);
|
|
35590
35698
|
} else {
|
|
35591
|
-
const routePath = "/api/" +
|
|
35699
|
+
const routePath = "/api/" + path33.join("/");
|
|
35592
35700
|
const [options, clientOptions] = args;
|
|
35593
35701
|
return client(routePath, options?.method || "GET", options, clientOptions);
|
|
35594
35702
|
}
|
|
35595
35703
|
}
|
|
35596
35704
|
});
|
|
35597
|
-
routeMeta.set(proxy, { path: [...
|
|
35705
|
+
routeMeta.set(proxy, { path: [...path33], baseURL });
|
|
35598
35706
|
return proxy;
|
|
35599
35707
|
}
|
|
35600
35708
|
__name(createNestedProxy, "createNestedProxy");
|
|
@@ -35634,9 +35742,9 @@ function createServerAPIClient(endpoints, options = {}) {
|
|
|
35634
35742
|
return endpoints;
|
|
35635
35743
|
}
|
|
35636
35744
|
__name(createServerAPIClient, "createServerAPIClient");
|
|
35637
|
-
function buildCacheKey(method,
|
|
35745
|
+
function buildCacheKey(method, path33, input, baseURL) {
|
|
35638
35746
|
const keyInput = input && typeof input === "object" ? { query: input.query, body: input.body } : input;
|
|
35639
|
-
const url = new URL(
|
|
35747
|
+
const url = new URL(path33, baseURL);
|
|
35640
35748
|
return `${method}:${url.origin}${url.pathname}:${stableStringify(keyInput ?? {})}`;
|
|
35641
35749
|
}
|
|
35642
35750
|
__name(buildCacheKey, "buildCacheKey");
|
|
@@ -35865,18 +35973,18 @@ function farmApiPlugin(options = {}) {
|
|
|
35865
35973
|
enforce: "pre",
|
|
35866
35974
|
configureServer(server) {
|
|
35867
35975
|
const discoverFileRoutes = /* @__PURE__ */ __name(async (apiDir) => {
|
|
35868
|
-
const
|
|
35869
|
-
const
|
|
35870
|
-
if (!
|
|
35976
|
+
const fs10 = await import("fs");
|
|
35977
|
+
const path33 = await import("path");
|
|
35978
|
+
if (!fs10.existsSync(apiDir)) {
|
|
35871
35979
|
log("No api directory found");
|
|
35872
35980
|
return;
|
|
35873
35981
|
}
|
|
35874
35982
|
const findRouteFiles = /* @__PURE__ */ __name((dir) => {
|
|
35875
35983
|
const files = [];
|
|
35876
|
-
if (!
|
|
35877
|
-
const entries =
|
|
35984
|
+
if (!fs10.existsSync(dir)) return files;
|
|
35985
|
+
const entries = fs10.readdirSync(dir, { withFileTypes: true });
|
|
35878
35986
|
for (const entry of entries) {
|
|
35879
|
-
const fullPath =
|
|
35987
|
+
const fullPath = path33.join(dir, entry.name);
|
|
35880
35988
|
if (entry.isDirectory()) {
|
|
35881
35989
|
files.push(...findRouteFiles(fullPath));
|
|
35882
35990
|
} else if (entry.name === "route.ts" || entry.name === "route.tsx" || entry.name === "route.js") {
|
|
@@ -35889,7 +35997,7 @@ function farmApiPlugin(options = {}) {
|
|
|
35889
35997
|
apiRoutesCache.clear();
|
|
35890
35998
|
for (const filePath of routeFiles) {
|
|
35891
35999
|
try {
|
|
35892
|
-
const relativePath2 =
|
|
36000
|
+
const relativePath2 = path33.relative(apiDir, path33.dirname(filePath));
|
|
35893
36001
|
const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
|
|
35894
36002
|
const routeModule = await server.ssrLoadModule(filePath);
|
|
35895
36003
|
const endpoints = {};
|
|
@@ -35915,15 +36023,15 @@ function farmApiPlugin(options = {}) {
|
|
|
35915
36023
|
}
|
|
35916
36024
|
}, "discoverFileRoutes");
|
|
35917
36025
|
const discoverRootRoutes = /* @__PURE__ */ __name(async () => {
|
|
35918
|
-
const
|
|
35919
|
-
const
|
|
36026
|
+
const fs10 = await import("fs");
|
|
36027
|
+
const path33 = await import("path");
|
|
35920
36028
|
const routesFiles = [
|
|
35921
|
-
|
|
35922
|
-
|
|
35923
|
-
|
|
36029
|
+
path33.join(server.config.root, srcDir, "routes.ts"),
|
|
36030
|
+
path33.join(server.config.root, srcDir, "routes.tsx"),
|
|
36031
|
+
path33.join(server.config.root, srcDir, "routes.js")
|
|
35924
36032
|
];
|
|
35925
36033
|
for (const routesFile of routesFiles) {
|
|
35926
|
-
if (
|
|
36034
|
+
if (fs10.existsSync(routesFile)) {
|
|
35927
36035
|
try {
|
|
35928
36036
|
const routesModule = await server.ssrLoadModule(routesFile);
|
|
35929
36037
|
for (const [exportName, exportValue] of Object.entries(routesModule)) {
|
|
@@ -35943,8 +36051,8 @@ function farmApiPlugin(options = {}) {
|
|
|
35943
36051
|
}
|
|
35944
36052
|
}, "discoverRootRoutes");
|
|
35945
36053
|
const discoverProgrammaticRoutes = /* @__PURE__ */ __name(async () => {
|
|
35946
|
-
const
|
|
35947
|
-
const srcRoot =
|
|
36054
|
+
const path33 = await import("path");
|
|
36055
|
+
const srcRoot = path33.join(server.config.root, srcDir);
|
|
35948
36056
|
const routeFiles = findProgrammaticRouteFilesInDir(srcRoot);
|
|
35949
36057
|
for (const routeFile of routeFiles) {
|
|
35950
36058
|
try {
|
|
@@ -35968,8 +36076,8 @@ function farmApiPlugin(options = {}) {
|
|
|
35968
36076
|
}
|
|
35969
36077
|
}, "discoverProgrammaticRoutes");
|
|
35970
36078
|
const initializeDiscovery = /* @__PURE__ */ __name(async () => {
|
|
35971
|
-
const
|
|
35972
|
-
const apiDir =
|
|
36079
|
+
const path33 = await import("path");
|
|
36080
|
+
const apiDir = path33.join(server.config.root, srcDir, "api");
|
|
35973
36081
|
log(`Discovering API routes in: ${apiDir}`);
|
|
35974
36082
|
await discoverFileRoutes(apiDir);
|
|
35975
36083
|
await discoverRootRoutes();
|
|
@@ -36137,9 +36245,9 @@ function farmApiPlugin(options = {}) {
|
|
|
36137
36245
|
}
|
|
36138
36246
|
} else {
|
|
36139
36247
|
try {
|
|
36140
|
-
const
|
|
36141
|
-
const apiDir =
|
|
36142
|
-
const relativePath2 =
|
|
36248
|
+
const path33 = await import("path");
|
|
36249
|
+
const apiDir = path33.join(server.config.root, srcDir, "api");
|
|
36250
|
+
const relativePath2 = path33.relative(apiDir, path33.dirname(file));
|
|
36143
36251
|
const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
|
|
36144
36252
|
const routeModule = await server.ssrLoadModule(file);
|
|
36145
36253
|
const endpoints = {};
|
|
@@ -36580,8 +36688,8 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
|
|
|
36580
36688
|
/**
|
|
36581
36689
|
* Set the base path for this middleware chain (called by manager when loading)
|
|
36582
36690
|
*/
|
|
36583
|
-
setBasePath(
|
|
36584
|
-
this.basePath =
|
|
36691
|
+
setBasePath(path33) {
|
|
36692
|
+
this.basePath = path33 === "/" ? "/" : path33.endsWith("/") ? path33.slice(0, -1) : path33;
|
|
36585
36693
|
}
|
|
36586
36694
|
use(fn) {
|
|
36587
36695
|
this.handlers.push(fn);
|
|
@@ -38471,10 +38579,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
38471
38579
|
}
|
|
38472
38580
|
__name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
|
|
38473
38581
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
38474
|
-
const
|
|
38582
|
+
const fs10 = await import("fs/promises");
|
|
38475
38583
|
const manifestPath = import_path10.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
38476
|
-
await
|
|
38477
|
-
await
|
|
38584
|
+
await fs10.mkdir(directory, { recursive: true });
|
|
38585
|
+
await fs10.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
38478
38586
|
`);
|
|
38479
38587
|
return manifestPath;
|
|
38480
38588
|
}
|
|
@@ -38520,7 +38628,7 @@ __name(normalizeManifestSource, "normalizeManifestSource");
|
|
|
38520
38628
|
// src/nitro/vercel-route-runtime.ts
|
|
38521
38629
|
var import_path11 = __toESM(require("path"));
|
|
38522
38630
|
init_route_runtime();
|
|
38523
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
38631
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs10) {
|
|
38524
38632
|
const dynamicRoutes = manifest.routes.filter(
|
|
38525
38633
|
(route2) => route2.rendering === "dynamic" && route2.runtime !== "edge"
|
|
38526
38634
|
);
|
|
@@ -38551,8 +38659,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs9) {
|
|
|
38551
38659
|
groupIndex += 1;
|
|
38552
38660
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
38553
38661
|
const functionDir = import_path11.default.join(functionsDir, `${functionName}.func`);
|
|
38554
|
-
await
|
|
38555
|
-
await configureVercelFunction(functionDir, group.config,
|
|
38662
|
+
await fs10.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
38663
|
+
await configureVercelFunction(functionDir, group.config, fs10);
|
|
38556
38664
|
destinations.set(key, `/${functionName}`);
|
|
38557
38665
|
}
|
|
38558
38666
|
const routes = [];
|
|
@@ -38599,15 +38707,15 @@ function farmRoutePatternToVercelSource(pattern) {
|
|
|
38599
38707
|
return source || "/";
|
|
38600
38708
|
}
|
|
38601
38709
|
__name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
|
|
38602
|
-
async function configureVercelFunction(functionDir, config,
|
|
38710
|
+
async function configureVercelFunction(functionDir, config, fs10) {
|
|
38603
38711
|
const configPath = import_path11.default.join(functionDir, ".vc-config.json");
|
|
38604
|
-
const current = JSON.parse(await
|
|
38712
|
+
const current = JSON.parse(await fs10.readFile(configPath, "utf8"));
|
|
38605
38713
|
const next = {
|
|
38606
38714
|
...current,
|
|
38607
38715
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
38608
38716
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
38609
38717
|
};
|
|
38610
|
-
await
|
|
38718
|
+
await fs10.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
38611
38719
|
`);
|
|
38612
38720
|
}
|
|
38613
38721
|
__name(configureVercelFunction, "configureVercelFunction");
|
|
@@ -39249,7 +39357,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
39249
39357
|
}
|
|
39250
39358
|
__name(hasProjectPostcssConfig, "hasProjectPostcssConfig");
|
|
39251
39359
|
async function findFarmConfigPath(root) {
|
|
39252
|
-
const
|
|
39360
|
+
const fs10 = await import("fs/promises");
|
|
39253
39361
|
const candidates = [
|
|
39254
39362
|
"farm.config.ts",
|
|
39255
39363
|
"farm.config.mts",
|
|
@@ -39263,7 +39371,7 @@ async function findFarmConfigPath(root) {
|
|
|
39263
39371
|
for (const candidate of candidates) {
|
|
39264
39372
|
const resolvedPath = import_path12.default.join(root, candidate);
|
|
39265
39373
|
try {
|
|
39266
|
-
await
|
|
39374
|
+
await fs10.access(resolvedPath);
|
|
39267
39375
|
return resolvedPath;
|
|
39268
39376
|
} catch {
|
|
39269
39377
|
}
|
|
@@ -39290,13 +39398,13 @@ function hasFarmServerRuntimePlugins(config) {
|
|
|
39290
39398
|
}
|
|
39291
39399
|
__name(hasFarmServerRuntimePlugins, "hasFarmServerRuntimePlugins");
|
|
39292
39400
|
async function discoverMiddlewareRoutes(appDir) {
|
|
39293
|
-
const
|
|
39401
|
+
const fs10 = await import("fs/promises");
|
|
39294
39402
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
39295
39403
|
const routes = /* @__PURE__ */ new Map();
|
|
39296
39404
|
async function walk(dir, routePath, discovered) {
|
|
39297
39405
|
let entries;
|
|
39298
39406
|
try {
|
|
39299
|
-
entries = await
|
|
39407
|
+
entries = await fs10.readdir(dir, { withFileTypes: true });
|
|
39300
39408
|
} catch {
|
|
39301
39409
|
return;
|
|
39302
39410
|
}
|
|
@@ -39377,12 +39485,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39377
39485
|
})
|
|
39378
39486
|
);
|
|
39379
39487
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
39380
|
-
const
|
|
39488
|
+
const fs10 = await import("fs/promises");
|
|
39381
39489
|
const layoutRoutes = [];
|
|
39382
39490
|
const appDir = import_path12.default.join(root, srcDir, "app");
|
|
39383
39491
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
39384
39492
|
try {
|
|
39385
|
-
const entries = await
|
|
39493
|
+
const entries = await fs10.readdir(dir, { withFileTypes: true });
|
|
39386
39494
|
for (const entry of entries) {
|
|
39387
39495
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?)$/)) {
|
|
39388
39496
|
layoutRoutes.push({
|
|
@@ -39516,7 +39624,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
39516
39624
|
}
|
|
39517
39625
|
__name(buildUniversal, "buildUniversal");
|
|
39518
39626
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
39519
|
-
const
|
|
39627
|
+
const fs10 = await import("fs/promises");
|
|
39520
39628
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
39521
39629
|
if (output.type !== "asset") continue;
|
|
39522
39630
|
if (fileName === "farm-fonts.css") {
|
|
@@ -39524,29 +39632,29 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
39524
39632
|
continue;
|
|
39525
39633
|
}
|
|
39526
39634
|
const filePath = import_path12.default.join(outputDir, fileName);
|
|
39527
|
-
await
|
|
39528
|
-
await
|
|
39635
|
+
await fs10.mkdir(import_path12.default.dirname(filePath), { recursive: true });
|
|
39636
|
+
await fs10.writeFile(filePath, output.source);
|
|
39529
39637
|
}
|
|
39530
39638
|
}
|
|
39531
39639
|
__name(writeSSRAssetsToClient, "writeSSRAssetsToClient");
|
|
39532
39640
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
39533
|
-
const
|
|
39641
|
+
const fs10 = await import("fs/promises");
|
|
39534
39642
|
await Promise.all(
|
|
39535
39643
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
39536
39644
|
const targetPath = import_path12.default.join(outputDir, url.replace(/^\/+/, ""));
|
|
39537
|
-
await
|
|
39538
|
-
await
|
|
39645
|
+
await fs10.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
|
|
39646
|
+
await fs10.copyFile(sourcePath, targetPath);
|
|
39539
39647
|
})
|
|
39540
39648
|
);
|
|
39541
39649
|
}
|
|
39542
39650
|
__name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
39543
39651
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
39544
|
-
const
|
|
39652
|
+
const fs10 = await import("fs/promises");
|
|
39545
39653
|
const fontCssPath = import_path12.default.join(outputDir, "farm-fonts.css");
|
|
39546
39654
|
let fontCss = fontCssSource;
|
|
39547
39655
|
if (fontCss === void 0) {
|
|
39548
39656
|
try {
|
|
39549
|
-
fontCss = await
|
|
39657
|
+
fontCss = await fs10.readFile(fontCssPath);
|
|
39550
39658
|
} catch {
|
|
39551
39659
|
return;
|
|
39552
39660
|
}
|
|
@@ -39554,12 +39662,12 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
39554
39662
|
const clientCssPath = import_path12.default.join(outputDir, "farm-client.css");
|
|
39555
39663
|
let clientCss = "";
|
|
39556
39664
|
try {
|
|
39557
|
-
clientCss = await
|
|
39665
|
+
clientCss = await fs10.readFile(clientCssPath, "utf8");
|
|
39558
39666
|
} catch {
|
|
39559
39667
|
}
|
|
39560
39668
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
39561
|
-
await
|
|
39562
|
-
await
|
|
39669
|
+
await fs10.writeFile(fontCssPath, normalizedFontCss);
|
|
39670
|
+
await fs10.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
39563
39671
|
}
|
|
39564
39672
|
__name(mergeBuiltFontCss, "mergeBuiltFontCss");
|
|
39565
39673
|
var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
|
|
@@ -39571,11 +39679,11 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
|
|
|
39571
39679
|
__name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
|
|
39572
39680
|
var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
39573
39681
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
39574
|
-
const
|
|
39682
|
+
const fs10 = await import("fs/promises");
|
|
39575
39683
|
const clientEntryPath = import_path12.default.join(outputDir, "farm-client.js");
|
|
39576
39684
|
let clientEntrySize = 0;
|
|
39577
39685
|
try {
|
|
39578
|
-
const clientEntry = await
|
|
39686
|
+
const clientEntry = await fs10.stat(clientEntryPath);
|
|
39579
39687
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
39580
39688
|
} catch {
|
|
39581
39689
|
}
|
|
@@ -39586,12 +39694,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
39586
39694
|
const globalsCssPath = import_path12.default.join(root, srcDir, "app", "globals.css");
|
|
39587
39695
|
let expectsCss = false;
|
|
39588
39696
|
try {
|
|
39589
|
-
const globalsCss = await
|
|
39697
|
+
const globalsCss = await fs10.readFile(globalsCssPath, "utf8");
|
|
39590
39698
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
39591
39699
|
} catch {
|
|
39592
39700
|
}
|
|
39593
39701
|
try {
|
|
39594
|
-
const clientCss = await
|
|
39702
|
+
const clientCss = await fs10.stat(clientCssPath);
|
|
39595
39703
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
39596
39704
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
39597
39705
|
}
|
|
@@ -39600,7 +39708,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
39600
39708
|
if (expectsCss) {
|
|
39601
39709
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
39602
39710
|
}
|
|
39603
|
-
await
|
|
39711
|
+
await fs10.writeFile(clientCssPath, "");
|
|
39604
39712
|
}
|
|
39605
39713
|
}
|
|
39606
39714
|
__name(validateClientBuildOutput, "validateClientBuildOutput");
|
|
@@ -39608,7 +39716,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39608
39716
|
const viteBuild = productionVite.build;
|
|
39609
39717
|
const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
|
|
39610
39718
|
const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
|
|
39611
|
-
const
|
|
39719
|
+
const fs10 = await import("fs/promises");
|
|
39612
39720
|
const pluginManager = new PluginManager2({
|
|
39613
39721
|
config,
|
|
39614
39722
|
isDev: false,
|
|
@@ -39644,6 +39752,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39644
39752
|
const applicableClientLayouts = clientLayouts.filter(
|
|
39645
39753
|
(layout2) => layout2.shouldHydrate && layoutAppliesToRoute(layout2.pattern, route2.pattern)
|
|
39646
39754
|
);
|
|
39755
|
+
if (metadata.suppressedAsyncHydration) {
|
|
39756
|
+
logger.warn(
|
|
39757
|
+
`\u26A0\uFE0F ${route2.pattern} is an async server component that imports client components; React cannot hydrate async components, so the route stays server-rendered and its client imports are not interactive.`
|
|
39758
|
+
);
|
|
39759
|
+
}
|
|
39647
39760
|
if (metadata.shouldHydrate || applicableClientLayouts.length > 0) {
|
|
39648
39761
|
const relativePath2 = route2.modulePath.replace(root, "").replace(/^\//, "");
|
|
39649
39762
|
const hydrationStrategies = [
|
|
@@ -39702,8 +39815,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39702
39815
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout2) => layout2.shouldHydrate).length} layouts, and ${clientRouteSlots.length} slots`
|
|
39703
39816
|
);
|
|
39704
39817
|
const clientEntryRoot = import_path12.default.join(root, ".farm", "tmp");
|
|
39705
|
-
await
|
|
39706
|
-
const clientEntryDir = await
|
|
39818
|
+
await fs10.mkdir(clientEntryRoot, { recursive: true });
|
|
39819
|
+
const clientEntryDir = await fs10.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
|
|
39707
39820
|
const clientEntryPath = import_path12.default.join(clientEntryDir, "farm-client-entry.tsx");
|
|
39708
39821
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
39709
39822
|
clientPages,
|
|
@@ -39717,7 +39830,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39717
39830
|
config.i18n,
|
|
39718
39831
|
config.plugins
|
|
39719
39832
|
);
|
|
39720
|
-
await
|
|
39833
|
+
await fs10.writeFile(clientEntryPath, clientHydrationCode);
|
|
39721
39834
|
const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
|
|
39722
39835
|
let postcssSearchPath;
|
|
39723
39836
|
let tailwindVitePlugin = void 0;
|
|
@@ -39725,7 +39838,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39725
39838
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
39726
39839
|
} else {
|
|
39727
39840
|
const postcssConfigPath = import_path12.default.join(clientEntryDir, "postcss.config.cjs");
|
|
39728
|
-
await
|
|
39841
|
+
await fs10.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
39729
39842
|
postcssSearchPath = clientEntryDir;
|
|
39730
39843
|
try {
|
|
39731
39844
|
const tailwindVite = (await import("@tailwindcss/vite")).default;
|
|
@@ -39870,7 +39983,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
39870
39983
|
await validateClientBuildOutput(root, srcDir, outputDir);
|
|
39871
39984
|
} finally {
|
|
39872
39985
|
try {
|
|
39873
|
-
await
|
|
39986
|
+
await fs10.rm(clientEntryDir, { recursive: true, force: true });
|
|
39874
39987
|
} catch {
|
|
39875
39988
|
}
|
|
39876
39989
|
}
|
|
@@ -40521,6 +40634,13 @@ async function createMatchedHydrationElement(matched, pathname, searchParams) {
|
|
|
40521
40634
|
if (matched.route.pageShouldHydrate) {
|
|
40522
40635
|
const Component = await loadRouteComponent(matched.route);
|
|
40523
40636
|
if (!Component) return null;
|
|
40637
|
+
if (typeof Component === "function" && Component.constructor && Component.constructor.name === "AsyncFunction") {
|
|
40638
|
+
console.warn(
|
|
40639
|
+
"[Farm.js] Skipping hydration for " + pathname +
|
|
40640
|
+
": async server components cannot run in the browser. Server-rendered HTML is preserved."
|
|
40641
|
+
);
|
|
40642
|
+
return null;
|
|
40643
|
+
}
|
|
40524
40644
|
const props = { params: params, searchParams: Promise.resolve(searchParams) };
|
|
40525
40645
|
pageElement = React.createElement(Component, props);
|
|
40526
40646
|
} else if (hydrateLayouts) {
|
|
@@ -41178,7 +41298,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41178
41298
|
const viteBuild = productionVite.build;
|
|
41179
41299
|
const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
|
|
41180
41300
|
const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
|
|
41181
|
-
const
|
|
41301
|
+
const fs10 = await import("fs/promises");
|
|
41182
41302
|
const pluginManager = new PluginManager2({
|
|
41183
41303
|
config,
|
|
41184
41304
|
isDev: false,
|
|
@@ -41189,8 +41309,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41189
41309
|
let postcssConfigDir;
|
|
41190
41310
|
let tailwindVitePlugin = void 0;
|
|
41191
41311
|
if (!hasScopedPostcssConfig) {
|
|
41192
|
-
postcssConfigDir = await
|
|
41193
|
-
await
|
|
41312
|
+
postcssConfigDir = await fs10.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
|
|
41313
|
+
await fs10.writeFile(
|
|
41194
41314
|
import_path12.default.join(postcssConfigDir, "postcss.config.cjs"),
|
|
41195
41315
|
"module.exports = { plugins: [] };\n"
|
|
41196
41316
|
);
|
|
@@ -41220,7 +41340,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41220
41340
|
fileName: entry.fileName,
|
|
41221
41341
|
sourceType: "static",
|
|
41222
41342
|
staticInfo: entry.staticInfo,
|
|
41223
|
-
data: (await
|
|
41343
|
+
data: (await fs10.readFile(entry.modulePath)).toString("base64")
|
|
41224
41344
|
});
|
|
41225
41345
|
continue;
|
|
41226
41346
|
}
|
|
@@ -41270,7 +41390,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41270
41390
|
for (const ext of notFoundExtensions) {
|
|
41271
41391
|
const checkPath = import_path12.default.join(sourceAppDir, `not-found${ext}`);
|
|
41272
41392
|
try {
|
|
41273
|
-
await
|
|
41393
|
+
await fs10.access(checkPath);
|
|
41274
41394
|
notFoundPath = checkPath;
|
|
41275
41395
|
break;
|
|
41276
41396
|
} catch {
|
|
@@ -41482,7 +41602,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
41482
41602
|
} finally {
|
|
41483
41603
|
if (postcssConfigDir) {
|
|
41484
41604
|
try {
|
|
41485
|
-
await
|
|
41605
|
+
await fs10.rm(postcssConfigDir, { recursive: true, force: true });
|
|
41486
41606
|
} catch {
|
|
41487
41607
|
}
|
|
41488
41608
|
}
|
|
@@ -44377,7 +44497,7 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
44377
44497
|
}
|
|
44378
44498
|
__name(getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
|
|
44379
44499
|
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroRuntimeResultPromise, pluginManager) {
|
|
44380
|
-
const [
|
|
44500
|
+
const [fs10, nitroRuntimeResult] = await Promise.all([
|
|
44381
44501
|
import("fs/promises"),
|
|
44382
44502
|
nitroRuntimeResultPromise
|
|
44383
44503
|
]);
|
|
@@ -44455,11 +44575,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
44455
44575
|
}
|
|
44456
44576
|
const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
|
|
44457
44577
|
const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
|
|
44458
|
-
await
|
|
44578
|
+
await fs10.mkdir(ssrOutputDir, { recursive: true });
|
|
44459
44579
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
44460
44580
|
const filePath = import_path12.default.join(ssrOutputDir, fileName);
|
|
44461
|
-
await
|
|
44462
|
-
await
|
|
44581
|
+
await fs10.mkdir(import_path12.default.dirname(filePath), { recursive: true });
|
|
44582
|
+
await fs10.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
44463
44583
|
}
|
|
44464
44584
|
const nitroEntryPath = import_path12.default.join(ssrOutputDir, "nitro-entry.mjs");
|
|
44465
44585
|
const nitroEntryCode = `
|
|
@@ -44525,10 +44645,10 @@ export default async function farmNitroEventHandler(event) {
|
|
|
44525
44645
|
return response
|
|
44526
44646
|
}
|
|
44527
44647
|
`.trim();
|
|
44528
|
-
await
|
|
44648
|
+
await fs10.writeFile(nitroEntryPath, nitroEntryCode);
|
|
44529
44649
|
const farmNodeServerEntryPath = preset === "node-server" ? import_path12.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
44530
44650
|
if (farmNodeServerEntryPath) {
|
|
44531
|
-
await
|
|
44651
|
+
await fs10.writeFile(
|
|
44532
44652
|
farmNodeServerEntryPath,
|
|
44533
44653
|
createFarmNodeServerEntry({
|
|
44534
44654
|
nitroEntryFile: import_path12.default.basename(nitroEntryPath),
|
|
@@ -44728,9 +44848,9 @@ export default async function farmNitroEventHandler(event) {
|
|
|
44728
44848
|
import_path12.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
44729
44849
|
{},
|
|
44730
44850
|
false,
|
|
44731
|
-
|
|
44851
|
+
fs10
|
|
44732
44852
|
);
|
|
44733
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
44853
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs10);
|
|
44734
44854
|
});
|
|
44735
44855
|
});
|
|
44736
44856
|
}
|
|
@@ -44762,17 +44882,17 @@ export default async function farmNitroEventHandler(event) {
|
|
|
44762
44882
|
import_path12.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
44763
44883
|
configuredEsbuildOptions,
|
|
44764
44884
|
effectiveMinify,
|
|
44765
|
-
|
|
44885
|
+
fs10
|
|
44766
44886
|
) : Promise.resolve(),
|
|
44767
|
-
imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"),
|
|
44768
|
-
useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"),
|
|
44887
|
+
imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs10) : Promise.resolve(),
|
|
44888
|
+
useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs10) : Promise.resolve()
|
|
44769
44889
|
]);
|
|
44770
44890
|
const failedCopy = copyResults.find(
|
|
44771
44891
|
(result) => result.status === "rejected"
|
|
44772
44892
|
);
|
|
44773
44893
|
if (failedCopy) throw failedCopy.reason;
|
|
44774
44894
|
if (canReusePrebuiltSSR) {
|
|
44775
|
-
await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile,
|
|
44895
|
+
await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs10);
|
|
44776
44896
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
44777
44897
|
}
|
|
44778
44898
|
if (useRolldownBuilder) {
|
|
@@ -44787,12 +44907,12 @@ export default async function farmNitroEventHandler(event) {
|
|
|
44787
44907
|
});
|
|
44788
44908
|
}
|
|
44789
44909
|
if (isVercel) {
|
|
44790
|
-
await postProcessVercelOutput(root, outputDir,
|
|
44910
|
+
await postProcessVercelOutput(root, outputDir, fs10, config, farmWorkflows, routeRuntimeManifest);
|
|
44791
44911
|
}
|
|
44792
44912
|
logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
|
|
44793
44913
|
}
|
|
44794
44914
|
__name(buildNitroUniversal, "buildNitroUniversal");
|
|
44795
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify,
|
|
44915
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify, fs10) {
|
|
44796
44916
|
const {
|
|
44797
44917
|
include: _include,
|
|
44798
44918
|
exclude: _exclude,
|
|
@@ -44809,13 +44929,13 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
|
|
|
44809
44929
|
"node18"
|
|
44810
44930
|
);
|
|
44811
44931
|
const transform = minify || hasConfiguredTransforms ? (await import("esbuild")).transform : null;
|
|
44812
|
-
await
|
|
44932
|
+
await fs10.rm(targetDir, { recursive: true, force: true });
|
|
44813
44933
|
await Promise.all(
|
|
44814
44934
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
44815
44935
|
const targetPath = import_path12.default.join(targetDir, fileName);
|
|
44816
|
-
await
|
|
44936
|
+
await fs10.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
|
|
44817
44937
|
if (output.type === "asset") {
|
|
44818
|
-
await
|
|
44938
|
+
await fs10.writeFile(targetPath, output.source);
|
|
44819
44939
|
return;
|
|
44820
44940
|
}
|
|
44821
44941
|
let code = output.code;
|
|
@@ -44826,14 +44946,14 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
|
|
|
44826
44946
|
});
|
|
44827
44947
|
code = result.code;
|
|
44828
44948
|
}
|
|
44829
|
-
await
|
|
44949
|
+
await fs10.writeFile(targetPath, code);
|
|
44830
44950
|
})
|
|
44831
44951
|
);
|
|
44832
44952
|
}
|
|
44833
44953
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
44834
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
44954
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs10) {
|
|
44835
44955
|
const packagePath = import_path12.default.join(serverDir, "package.json");
|
|
44836
|
-
const packageJSON = await
|
|
44956
|
+
const packageJSON = await fs10.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
44837
44957
|
if (error.code === "ENOENT") return { type: "module" };
|
|
44838
44958
|
throw error;
|
|
44839
44959
|
});
|
|
@@ -44843,38 +44963,38 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs9) {
|
|
|
44843
44963
|
...existingImports,
|
|
44844
44964
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
44845
44965
|
};
|
|
44846
|
-
await
|
|
44847
|
-
await
|
|
44966
|
+
await fs10.mkdir(serverDir, { recursive: true });
|
|
44967
|
+
await fs10.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
44848
44968
|
`);
|
|
44849
44969
|
}
|
|
44850
44970
|
__name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
|
|
44851
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
44971
|
+
async function postProcessVercelOutput(root, outputDir, fs10, config, farmWorkflows, routeRuntimeManifest) {
|
|
44852
44972
|
const serverDir = import_path12.default.join(outputDir, "server");
|
|
44853
44973
|
const functionsDir = import_path12.default.join(outputDir, "functions");
|
|
44854
44974
|
const nitroFuncDir = import_path12.default.join(functionsDir, "__nitro.func");
|
|
44855
44975
|
const staticDir = import_path12.default.join(outputDir, "static");
|
|
44856
44976
|
const publicDir = import_path12.default.join(outputDir, "public");
|
|
44857
|
-
await
|
|
44858
|
-
const serverContents = await
|
|
44977
|
+
await fs10.mkdir(nitroFuncDir, { recursive: true });
|
|
44978
|
+
const serverContents = await fs10.readdir(serverDir);
|
|
44859
44979
|
for (const file of serverContents) {
|
|
44860
44980
|
const src = import_path12.default.join(serverDir, file);
|
|
44861
44981
|
const dest = import_path12.default.join(nitroFuncDir, file);
|
|
44862
|
-
await
|
|
44982
|
+
await fs10.rename(src, dest);
|
|
44863
44983
|
}
|
|
44864
|
-
await
|
|
44984
|
+
await fs10.rmdir(serverDir);
|
|
44865
44985
|
try {
|
|
44866
|
-
await
|
|
44986
|
+
await fs10.rename(publicDir, staticDir);
|
|
44867
44987
|
} catch {
|
|
44868
44988
|
}
|
|
44869
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
44870
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
44989
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs10);
|
|
44990
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs10);
|
|
44871
44991
|
const configPath = import_path12.default.join(outputDir, "config.json");
|
|
44872
|
-
const configContent = await
|
|
44992
|
+
const configContent = await fs10.readFile(configPath, "utf-8");
|
|
44873
44993
|
const vercelConfig = JSON.parse(configContent);
|
|
44874
44994
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
44875
44995
|
outputDir,
|
|
44876
44996
|
routeRuntimeManifest,
|
|
44877
|
-
|
|
44997
|
+
fs10
|
|
44878
44998
|
);
|
|
44879
44999
|
vercelConfig.routes = [
|
|
44880
45000
|
// Apply the header before the filesystem handler. `continue` lets Vercel
|
|
@@ -44909,24 +45029,24 @@ async function postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflo
|
|
|
44909
45029
|
vercelConfigWithWorkflowCrons,
|
|
44910
45030
|
config.cron.jobs
|
|
44911
45031
|
);
|
|
44912
|
-
await
|
|
45032
|
+
await fs10.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
44913
45033
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
44914
45034
|
}
|
|
44915
45035
|
__name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
44916
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
45036
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs10) {
|
|
44917
45037
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
44918
45038
|
if (!docsContentDir) return;
|
|
44919
45039
|
const bundledContentDir = import_path12.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
|
|
44920
45040
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
44921
45041
|
fallback: "now"
|
|
44922
45042
|
});
|
|
44923
|
-
await
|
|
44924
|
-
await
|
|
44925
|
-
await
|
|
45043
|
+
await fs10.rm(bundledContentDir, { recursive: true, force: true });
|
|
45044
|
+
await fs10.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
|
|
45045
|
+
await fs10.cp(docsContentDir, bundledContentDir, {
|
|
44926
45046
|
recursive: true,
|
|
44927
45047
|
force: true
|
|
44928
45048
|
});
|
|
44929
|
-
await
|
|
45049
|
+
await fs10.writeFile(
|
|
44930
45050
|
import_path12.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
44931
45051
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
44932
45052
|
`
|
|
@@ -44934,7 +45054,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9) {
|
|
|
44934
45054
|
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path12.default.relative(root, docsContentDir)}`);
|
|
44935
45055
|
}
|
|
44936
45056
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
44937
|
-
async function copySharpRuntime(config, root, nitroFuncDir,
|
|
45057
|
+
async function copySharpRuntime(config, root, nitroFuncDir, fs10) {
|
|
44938
45058
|
if (config.images.provider === "none") return;
|
|
44939
45059
|
const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
|
|
44940
45060
|
let sharpRequire = projectRequire;
|
|
@@ -44958,18 +45078,18 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
|
|
|
44958
45078
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
44959
45079
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
44960
45080
|
if (!packageJsonPath) return;
|
|
44961
|
-
const packageJson = JSON.parse(await
|
|
45081
|
+
const packageJson = JSON.parse(await fs10.readFile(packageJsonPath, "utf8"));
|
|
44962
45082
|
const packageDir = import_path12.default.dirname(packageJsonPath);
|
|
44963
45083
|
const targetDir = import_path12.default.join(targetNodeModules, ...packageName.split("/"));
|
|
44964
45084
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
44965
|
-
await
|
|
45085
|
+
await fs10.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
|
|
44966
45086
|
const packageRequire = (0, import_module3.createRequire)(packageJsonPath);
|
|
44967
45087
|
const dependencies = {
|
|
44968
45088
|
...packageJson.dependencies,
|
|
44969
45089
|
...packageJson.optionalDependencies
|
|
44970
45090
|
};
|
|
44971
45091
|
await Promise.all([
|
|
44972
|
-
|
|
45092
|
+
fs10.cp(packageDir, targetDir, {
|
|
44973
45093
|
recursive: true,
|
|
44974
45094
|
force: true,
|
|
44975
45095
|
dereference: true,
|
|
@@ -44988,16 +45108,16 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
|
|
|
44988
45108
|
);
|
|
44989
45109
|
}
|
|
44990
45110
|
const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
|
|
44991
|
-
const functionPackage = JSON.parse(await
|
|
45111
|
+
const functionPackage = JSON.parse(await fs10.readFile(functionPackagePath, "utf8"));
|
|
44992
45112
|
functionPackage.dependencies = {
|
|
44993
45113
|
...functionPackage.dependencies,
|
|
44994
45114
|
...Object.fromEntries([...copiedPackages].sort(([left], [right]) => left.localeCompare(right)))
|
|
44995
45115
|
};
|
|
44996
|
-
await
|
|
45116
|
+
await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
|
|
44997
45117
|
logger.info(`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${copiedPackages.size} packages)`);
|
|
44998
45118
|
}
|
|
44999
45119
|
__name(copySharpRuntime, "copySharpRuntime");
|
|
45000
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
45120
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs10) {
|
|
45001
45121
|
const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
|
|
45002
45122
|
let runtimeRequire = projectRequire;
|
|
45003
45123
|
let packageJsonPath = resolvePackageJson(runtimeRequire, "@vercel/og");
|
|
@@ -45013,23 +45133,23 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs9) {
|
|
|
45013
45133
|
"Generated metadata images require @vercel/og. Reinstall @farm.js/core with production dependencies."
|
|
45014
45134
|
);
|
|
45015
45135
|
}
|
|
45016
|
-
const packageJson = JSON.parse(await
|
|
45136
|
+
const packageJson = JSON.parse(await fs10.readFile(packageJsonPath, "utf8"));
|
|
45017
45137
|
const packageDir = import_path12.default.dirname(packageJsonPath);
|
|
45018
45138
|
const targetDir = import_path12.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
45019
|
-
await
|
|
45020
|
-
await
|
|
45139
|
+
await fs10.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
|
|
45140
|
+
await fs10.cp(packageDir, targetDir, {
|
|
45021
45141
|
recursive: true,
|
|
45022
45142
|
force: true,
|
|
45023
45143
|
dereference: true,
|
|
45024
45144
|
mode: import_fs5.constants.COPYFILE_FICLONE
|
|
45025
45145
|
});
|
|
45026
45146
|
const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
|
|
45027
|
-
const functionPackage = JSON.parse(await
|
|
45147
|
+
const functionPackage = JSON.parse(await fs10.readFile(functionPackagePath, "utf8"));
|
|
45028
45148
|
functionPackage.dependencies = {
|
|
45029
45149
|
...functionPackage.dependencies,
|
|
45030
45150
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
45031
45151
|
};
|
|
45032
|
-
await
|
|
45152
|
+
await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
|
|
45033
45153
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
45034
45154
|
}
|
|
45035
45155
|
__name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
@@ -45043,7 +45163,7 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
45043
45163
|
return null;
|
|
45044
45164
|
}
|
|
45045
45165
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
45046
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
45166
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs10) {
|
|
45047
45167
|
const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
|
|
45048
45168
|
let prismaClientDir;
|
|
45049
45169
|
try {
|
|
@@ -45053,7 +45173,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
|
|
|
45053
45173
|
}
|
|
45054
45174
|
const generatedClientDir = import_path12.default.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
45055
45175
|
try {
|
|
45056
|
-
await
|
|
45176
|
+
await fs10.access(generatedClientDir);
|
|
45057
45177
|
} catch {
|
|
45058
45178
|
return;
|
|
45059
45179
|
}
|
|
@@ -45061,20 +45181,20 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
|
|
|
45061
45181
|
const targetPrismaScopeDir = import_path12.default.join(targetNodeModules, "@prisma");
|
|
45062
45182
|
const targetGeneratedDir = import_path12.default.join(targetNodeModules, ".prisma", "client");
|
|
45063
45183
|
const targetClientDir = import_path12.default.join(targetPrismaScopeDir, "client");
|
|
45064
|
-
await
|
|
45065
|
-
await
|
|
45184
|
+
await fs10.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
45185
|
+
await fs10.cp(prismaClientDir, targetClientDir, {
|
|
45066
45186
|
recursive: true,
|
|
45067
45187
|
force: true
|
|
45068
45188
|
});
|
|
45069
|
-
await
|
|
45189
|
+
await fs10.cp(generatedClientDir, targetGeneratedDir, {
|
|
45070
45190
|
recursive: true,
|
|
45071
45191
|
force: true
|
|
45072
45192
|
});
|
|
45073
45193
|
const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
|
|
45074
45194
|
const clientPackagePath = import_path12.default.join(prismaClientDir, "package.json");
|
|
45075
45195
|
const [functionPackageContent, clientPackageContent] = await Promise.all([
|
|
45076
|
-
|
|
45077
|
-
|
|
45196
|
+
fs10.readFile(functionPackagePath, "utf-8"),
|
|
45197
|
+
fs10.readFile(clientPackagePath, "utf-8")
|
|
45078
45198
|
]);
|
|
45079
45199
|
const functionPackage = JSON.parse(functionPackageContent);
|
|
45080
45200
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
@@ -45082,7 +45202,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
|
|
|
45082
45202
|
...functionPackage.dependencies,
|
|
45083
45203
|
"@prisma/client": clientPackage.version
|
|
45084
45204
|
};
|
|
45085
|
-
await
|
|
45205
|
+
await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
|
|
45086
45206
|
}
|
|
45087
45207
|
__name(copyPrismaClientForVercel, "copyPrismaClientForVercel");
|
|
45088
45208
|
|
|
@@ -45404,10 +45524,10 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
45404
45524
|
const manifestPath = import_path14.default.join(publicOutputDir, "farm-client-manifest.json");
|
|
45405
45525
|
const assetsDir = import_path14.default.join(publicOutputDir, "assets");
|
|
45406
45526
|
const manifestExists = await import("fs/promises").then(
|
|
45407
|
-
(
|
|
45527
|
+
(fs10) => fs10.access(manifestPath).then(() => true).catch(() => false)
|
|
45408
45528
|
);
|
|
45409
45529
|
const assetsExist = await import("fs/promises").then(
|
|
45410
|
-
(
|
|
45530
|
+
(fs10) => fs10.access(assetsDir).then(() => true).catch(() => false)
|
|
45411
45531
|
);
|
|
45412
45532
|
if (manifestExists && assetsExist) {
|
|
45413
45533
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -46670,10 +46790,10 @@ var _FarmClientPluginManager = class _FarmClientPluginManager {
|
|
|
46670
46790
|
if (session.signal.aborted) return Promise.resolve();
|
|
46671
46791
|
const clientWindow = this.options.window;
|
|
46672
46792
|
const schedule = clientWindow?.requestAnimationFrame ? (callback) => clientWindow.requestAnimationFrame(() => clientWindow.requestAnimationFrame(callback)) : (callback) => setTimeout(callback, 0);
|
|
46673
|
-
return new Promise((
|
|
46793
|
+
return new Promise((resolve7) => {
|
|
46674
46794
|
schedule(() => {
|
|
46675
46795
|
if (session.signal.aborted || this.closed) {
|
|
46676
|
-
|
|
46796
|
+
resolve7();
|
|
46677
46797
|
return;
|
|
46678
46798
|
}
|
|
46679
46799
|
void this.runHook(
|
|
@@ -46687,7 +46807,7 @@ var _FarmClientPluginManager = class _FarmClientPluginManager {
|
|
|
46687
46807
|
if (this.currentNavigation?.session === session) {
|
|
46688
46808
|
this.currentNavigation = void 0;
|
|
46689
46809
|
}
|
|
46690
|
-
|
|
46810
|
+
resolve7();
|
|
46691
46811
|
});
|
|
46692
46812
|
});
|
|
46693
46813
|
});
|