@farm.js/core 0.1.0-beta.16 → 0.1.0-beta.17
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/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/app-B0tE1I3o.d.ts +306 -0
- package/dist/app-Dv2JJb7X.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-AN3PQVKH.mjs → chunk-2FLBZFPG.mjs} +9 -7
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-SLDBGSC3.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-T2KL7VEL.mjs → chunk-PZXBQKCH.mjs} +13 -4
- package/dist/chunk-PZXBQKCH.mjs.map +1 -0
- package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
- package/dist/chunk-RIXKJPGI.mjs.map +1 -0
- package/dist/{chunk-OSWV5IJB.mjs → chunk-T2M5QANG.mjs} +32 -9
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-BWJC5ZOD.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-BWJC5ZOD.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
- package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
- package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-278AvYHE.d.mts +2021 -0
- package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/{devtools-E4YNCY5J.mjs → devtools-K2ERKGNI.mjs} +3 -3
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/docs.mjs +3 -3
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/font.d.mts +95 -0
- package/dist/font.d.ts +95 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/index.cjs +293 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.mjs +22 -18
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/internal/build-runtime.cjs +306 -137
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +41 -0
- package/dist/internal/build-runtime.d.ts +41 -0
- package/dist/internal/build-runtime.mjs +7 -7
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs +140 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/internal/metadata-image-runtime.d.mts +25 -0
- package/dist/internal/metadata-image-runtime.d.ts +25 -0
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +44 -0
- package/dist/internal/production-runtime.d.ts +44 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-DmCudMw_.d.mts +22 -0
- package/dist/metadata-xghtOlbR.d.ts +22 -0
- package/dist/middleware.cjs +116 -98
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +5 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +132 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +4 -4
- package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
- package/dist/production-runtime-DFN2_RXq.d.mts +79 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-Cq5d6qmE.d.mts +6 -0
- package/dist/request-LoxDW3lp.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-BA9TOSu1.d.mts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-DTAQ2HDv.d.ts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server.cjs +170 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +6 -6
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-B6GaYNJL.d.ts +23 -0
- package/dist/utils-CKSHiip6.d.mts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +140 -2
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +4 -4
- package/dist/workflows.d.mts +110 -0
- package/dist/workflows.d.ts +110 -0
- package/package.json +1 -1
- package/types/middleware.d.ts +36 -11
- package/dist/chunk-AN3PQVKH.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-OSWV5IJB.mjs.map +0 -1
- package/dist/chunk-T2KL7VEL.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- /package/dist/{chunk-SLDBGSC3.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{devtools-E4YNCY5J.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
|
@@ -5406,6 +5406,143 @@ var init_preload = __esm({
|
|
|
5406
5406
|
}
|
|
5407
5407
|
});
|
|
5408
5408
|
|
|
5409
|
+
// src/security.ts
|
|
5410
|
+
function resolveFarmSecurityConfig(input) {
|
|
5411
|
+
if (input === void 0) return { csp: false };
|
|
5412
|
+
if (!isPlainRecord(input)) {
|
|
5413
|
+
throw new TypeError("security must be an object containing the csp option.");
|
|
5414
|
+
}
|
|
5415
|
+
if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
|
|
5416
|
+
throw new TypeError(
|
|
5417
|
+
"security.contentSecurityPolicy is not supported. Use security.csp instead."
|
|
5418
|
+
);
|
|
5419
|
+
}
|
|
5420
|
+
const csp = input.csp;
|
|
5421
|
+
if (csp === void 0 || csp === false) return { csp: false };
|
|
5422
|
+
if (typeof csp === "string") {
|
|
5423
|
+
return {
|
|
5424
|
+
csp: {
|
|
5425
|
+
value: validateSerializedCsp(csp),
|
|
5426
|
+
reportOnly: false
|
|
5427
|
+
}
|
|
5428
|
+
};
|
|
5429
|
+
}
|
|
5430
|
+
if (!isPlainRecord(csp)) {
|
|
5431
|
+
throw new TypeError("security.csp must be a policy string, false, or an options object.");
|
|
5432
|
+
}
|
|
5433
|
+
const reportOnly = validateReportOnly(csp.reportOnly);
|
|
5434
|
+
if (Object.prototype.hasOwnProperty.call(csp, "value")) {
|
|
5435
|
+
if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
|
|
5436
|
+
throw new TypeError(
|
|
5437
|
+
"Resolved security.csp values cannot include policy or directives options."
|
|
5438
|
+
);
|
|
5439
|
+
}
|
|
5440
|
+
return {
|
|
5441
|
+
csp: {
|
|
5442
|
+
value: validateSerializedCsp(csp.value),
|
|
5443
|
+
reportOnly
|
|
5444
|
+
}
|
|
5445
|
+
};
|
|
5446
|
+
}
|
|
5447
|
+
const { policy, directives } = csp;
|
|
5448
|
+
if (policy !== void 0 && directives !== void 0) {
|
|
5449
|
+
throw new TypeError("security.csp accepts either policy or directives, not both.");
|
|
5450
|
+
}
|
|
5451
|
+
if (policy === void 0 && directives === void 0) {
|
|
5452
|
+
throw new TypeError("security.csp requires a policy string or directives object.");
|
|
5453
|
+
}
|
|
5454
|
+
return {
|
|
5455
|
+
csp: {
|
|
5456
|
+
value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
|
|
5457
|
+
reportOnly
|
|
5458
|
+
}
|
|
5459
|
+
};
|
|
5460
|
+
}
|
|
5461
|
+
function serializeFarmCspDirectives(directives) {
|
|
5462
|
+
if (!isPlainRecord(directives)) {
|
|
5463
|
+
throw new TypeError("security.csp.directives must be an object.");
|
|
5464
|
+
}
|
|
5465
|
+
const serialized = [];
|
|
5466
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
5467
|
+
for (const [configuredName, configuredValue] of Object.entries(directives)) {
|
|
5468
|
+
if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
|
|
5469
|
+
continue;
|
|
5470
|
+
}
|
|
5471
|
+
const name = normalizeDirectiveName(configuredName);
|
|
5472
|
+
if (normalizedNames.has(name)) {
|
|
5473
|
+
throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
|
|
5474
|
+
}
|
|
5475
|
+
normalizedNames.add(name);
|
|
5476
|
+
const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
|
|
5477
|
+
validateDirectiveValue
|
|
5478
|
+
);
|
|
5479
|
+
serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
|
|
5480
|
+
}
|
|
5481
|
+
if (serialized.length === 0) {
|
|
5482
|
+
throw new TypeError("security.csp.directives must contain at least one enabled directive.");
|
|
5483
|
+
}
|
|
5484
|
+
return serialized.join("; ");
|
|
5485
|
+
}
|
|
5486
|
+
function getFarmSecurityHeader(security) {
|
|
5487
|
+
if (!security.csp) return void 0;
|
|
5488
|
+
return {
|
|
5489
|
+
key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
|
|
5490
|
+
value: security.csp.value
|
|
5491
|
+
};
|
|
5492
|
+
}
|
|
5493
|
+
function normalizeDirectiveName(value) {
|
|
5494
|
+
const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
5495
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
5496
|
+
throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
|
|
5497
|
+
}
|
|
5498
|
+
return name;
|
|
5499
|
+
}
|
|
5500
|
+
function validateDirectiveValue(value) {
|
|
5501
|
+
if (typeof value !== "string") {
|
|
5502
|
+
throw new TypeError("security.csp directive values must be strings or booleans.");
|
|
5503
|
+
}
|
|
5504
|
+
const normalized = value.trim();
|
|
5505
|
+
if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
5506
|
+
throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
|
|
5507
|
+
}
|
|
5508
|
+
return normalized;
|
|
5509
|
+
}
|
|
5510
|
+
function validateSerializedCsp(value) {
|
|
5511
|
+
if (typeof value !== "string") {
|
|
5512
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
5513
|
+
}
|
|
5514
|
+
const normalized = value.trim().replace(/;+$/g, "").trim();
|
|
5515
|
+
if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
5516
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
5517
|
+
}
|
|
5518
|
+
return normalized;
|
|
5519
|
+
}
|
|
5520
|
+
function validateReportOnly(value) {
|
|
5521
|
+
if (value === void 0) return false;
|
|
5522
|
+
if (typeof value !== "boolean") {
|
|
5523
|
+
throw new TypeError("security.csp.reportOnly must be a boolean.");
|
|
5524
|
+
}
|
|
5525
|
+
return value;
|
|
5526
|
+
}
|
|
5527
|
+
function isPlainRecord(value) {
|
|
5528
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
5529
|
+
const prototype = Object.getPrototypeOf(value);
|
|
5530
|
+
return prototype === Object.prototype || prototype === null;
|
|
5531
|
+
}
|
|
5532
|
+
var init_security = __esm({
|
|
5533
|
+
"src/security.ts"() {
|
|
5534
|
+
"use strict";
|
|
5535
|
+
__name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
|
|
5536
|
+
__name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
|
|
5537
|
+
__name(getFarmSecurityHeader, "getFarmSecurityHeader");
|
|
5538
|
+
__name(normalizeDirectiveName, "normalizeDirectiveName");
|
|
5539
|
+
__name(validateDirectiveValue, "validateDirectiveValue");
|
|
5540
|
+
__name(validateSerializedCsp, "validateSerializedCsp");
|
|
5541
|
+
__name(validateReportOnly, "validateReportOnly");
|
|
5542
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
5543
|
+
}
|
|
5544
|
+
});
|
|
5545
|
+
|
|
5409
5546
|
// src/config-entry.ts
|
|
5410
5547
|
var init_config_entry = __esm({
|
|
5411
5548
|
"src/config-entry.ts"() {
|
|
@@ -5667,6 +5804,8 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5667
5804
|
const routeRules = normalizeRouteRules(userConfig.routeRules);
|
|
5668
5805
|
const routeRuleRedirects = routeRulesToRedirects(routeRules);
|
|
5669
5806
|
const routeRuleHeaders = routeRulesToHeaders(routeRules);
|
|
5807
|
+
const security = resolveFarmSecurityConfig(userConfig.security);
|
|
5808
|
+
const securityHeader = getFarmSecurityHeader(security);
|
|
5670
5809
|
const deploy = resolveDeployConfig(userConfig);
|
|
5671
5810
|
const root = userConfig.root || process.cwd();
|
|
5672
5811
|
const srcDir = userConfig.srcDir || "src";
|
|
@@ -5722,7 +5861,11 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5722
5861
|
trailingSlash: userConfig.trailingSlash ?? false,
|
|
5723
5862
|
redirects: /* @__PURE__ */ __name(() => [...redirects, ...routeRuleRedirects], "redirects"),
|
|
5724
5863
|
rewrites: /* @__PURE__ */ __name(() => rewrites, "rewrites"),
|
|
5725
|
-
headers: /* @__PURE__ */ __name(() => [
|
|
5864
|
+
headers: /* @__PURE__ */ __name(() => [
|
|
5865
|
+
...headers,
|
|
5866
|
+
...routeRuleHeaders,
|
|
5867
|
+
...securityHeader ? [{ source: "/*", headers: [securityHeader] }] : []
|
|
5868
|
+
], "headers"),
|
|
5726
5869
|
routeRules,
|
|
5727
5870
|
images: resolveFarmImageConfig(userConfig.images),
|
|
5728
5871
|
performance: resolveFarmPerformanceConfig(userConfig.performance),
|
|
@@ -5741,6 +5884,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5741
5884
|
notFound: userConfig.notFound || {},
|
|
5742
5885
|
context: userConfig.context || (() => void 0),
|
|
5743
5886
|
serverActions: resolveServerActionsConfig(userConfig.serverActions),
|
|
5887
|
+
security,
|
|
5744
5888
|
deploymentId,
|
|
5745
5889
|
output: userConfig.output || "standalone",
|
|
5746
5890
|
distDir: userConfig.distDir || ".farm",
|
|
@@ -5820,6 +5964,7 @@ var init_config2 = __esm({
|
|
|
5820
5964
|
init_config();
|
|
5821
5965
|
init_auth_config();
|
|
5822
5966
|
init_preload();
|
|
5967
|
+
init_security();
|
|
5823
5968
|
init_config_entry();
|
|
5824
5969
|
FARM_RESOLVED_CUSTOM_CONTEXT = /* @__PURE__ */ Symbol.for("farm.resolvedCustomContext");
|
|
5825
5970
|
__name(hasCustomFarmRouteContext, "hasCustomFarmRouteContext");
|
|
@@ -13540,6 +13685,7 @@ var init_app = __esm({
|
|
|
13540
13685
|
init_cache();
|
|
13541
13686
|
init_auth_config();
|
|
13542
13687
|
init_preload();
|
|
13688
|
+
init_security();
|
|
13543
13689
|
defaultDocsConfig = {
|
|
13544
13690
|
enabled: false,
|
|
13545
13691
|
entry: "/docs",
|
|
@@ -13604,6 +13750,7 @@ var init_app = __esm({
|
|
|
13604
13750
|
routeRules: normalizeRouteRules(config.routeRules),
|
|
13605
13751
|
context: config.context || (() => void 0),
|
|
13606
13752
|
serverActions: resolveServerActionsConfig(config.serverActions),
|
|
13753
|
+
security: resolveFarmSecurityConfig(config.security),
|
|
13607
13754
|
images: resolveFarmImageConfig(config.images),
|
|
13608
13755
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
13609
13756
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|
|
@@ -15242,6 +15389,126 @@ var init_fonts = __esm({
|
|
|
15242
15389
|
}
|
|
15243
15390
|
});
|
|
15244
15391
|
|
|
15392
|
+
// src/server/vite-config.ts
|
|
15393
|
+
function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
|
|
15394
|
+
const resolvedProjectRoot = import_node_path9.default.resolve(projectRoot);
|
|
15395
|
+
return appDirectories.map((appDirectory) => {
|
|
15396
|
+
const relativeAppDirectory = import_node_path9.default.relative(resolvedProjectRoot, import_node_path9.default.resolve(appDirectory)).replace(/\\/g, "/");
|
|
15397
|
+
const prefix = relativeAppDirectory || ".";
|
|
15398
|
+
return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
|
|
15399
|
+
});
|
|
15400
|
+
}
|
|
15401
|
+
function createFarmClientOptimizeDepsConfig(entries) {
|
|
15402
|
+
return {
|
|
15403
|
+
// Keep normal application dependency discovery for CJS-only packages, but
|
|
15404
|
+
// seed every Farm browser runtime so React is present in the first crawl.
|
|
15405
|
+
noDiscovery: false,
|
|
15406
|
+
// Waiting for the crawl avoids serving a partial optimizer generation and
|
|
15407
|
+
// then changing browser hashes while hydration is already in progress.
|
|
15408
|
+
holdUntilCrawlEnd: true,
|
|
15409
|
+
include: [...FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE],
|
|
15410
|
+
// Farm's HTML boots through a virtual module and imports route UI lazily.
|
|
15411
|
+
// Explicit entries let Vite finish that crawl before a navigation can
|
|
15412
|
+
// rotate the optimizer hash underneath a hydrated React runtime.
|
|
15413
|
+
...entries?.length ? { entries: [...entries] } : {}
|
|
15414
|
+
};
|
|
15415
|
+
}
|
|
15416
|
+
function createFarmSourceAlias(projectRoot, srcDir = "src") {
|
|
15417
|
+
return {
|
|
15418
|
+
"@": import_node_path9.default.resolve(projectRoot, srcDir)
|
|
15419
|
+
};
|
|
15420
|
+
}
|
|
15421
|
+
function mergeNoExternal(farmValue, userValue) {
|
|
15422
|
+
if (farmValue === true || userValue === true) return true;
|
|
15423
|
+
const normalize = /* @__PURE__ */ __name((value) => value == null || value === true ? [] : Array.isArray(value) ? value : [value], "normalize");
|
|
15424
|
+
return Array.from(/* @__PURE__ */ new Set([...normalize(farmValue), ...normalize(userValue)]));
|
|
15425
|
+
}
|
|
15426
|
+
function mergeAlias(farmValue, userValue) {
|
|
15427
|
+
if (!farmValue) return userValue || {};
|
|
15428
|
+
if (!userValue) return farmValue;
|
|
15429
|
+
if (!Array.isArray(farmValue) && !Array.isArray(userValue)) {
|
|
15430
|
+
return {
|
|
15431
|
+
...farmValue,
|
|
15432
|
+
...userValue
|
|
15433
|
+
};
|
|
15434
|
+
}
|
|
15435
|
+
const normalize = /* @__PURE__ */ __name((value) => Array.isArray(value) ? [...value] : Object.entries(value).map(([find, replacement]) => ({ find, replacement })), "normalize");
|
|
15436
|
+
return [...normalize(userValue), ...normalize(farmValue)];
|
|
15437
|
+
}
|
|
15438
|
+
function mergeFarmViteConfig(farmConfig, userConfig = {}) {
|
|
15439
|
+
const noDiscovery = userConfig.optimizeDeps?.noDiscovery ?? farmConfig.optimizeDeps?.noDiscovery;
|
|
15440
|
+
const holdUntilCrawlEnd = userConfig.optimizeDeps?.holdUntilCrawlEnd ?? (userConfig.optimizeDeps?.noDiscovery === true ? false : farmConfig.optimizeDeps?.holdUntilCrawlEnd);
|
|
15441
|
+
return {
|
|
15442
|
+
...farmConfig,
|
|
15443
|
+
...userConfig,
|
|
15444
|
+
plugins: [...farmConfig.plugins || [], ...userConfig.plugins || []],
|
|
15445
|
+
server: {
|
|
15446
|
+
...farmConfig.server,
|
|
15447
|
+
...userConfig.server
|
|
15448
|
+
},
|
|
15449
|
+
resolve: {
|
|
15450
|
+
...farmConfig.resolve,
|
|
15451
|
+
...userConfig.resolve,
|
|
15452
|
+
alias: mergeAlias(farmConfig.resolve?.alias, userConfig.resolve?.alias),
|
|
15453
|
+
dedupe: Array.from(
|
|
15454
|
+
/* @__PURE__ */ new Set([...farmConfig.resolve?.dedupe || [], ...userConfig.resolve?.dedupe || []])
|
|
15455
|
+
)
|
|
15456
|
+
},
|
|
15457
|
+
optimizeDeps: {
|
|
15458
|
+
...farmConfig.optimizeDeps,
|
|
15459
|
+
...userConfig.optimizeDeps,
|
|
15460
|
+
noDiscovery,
|
|
15461
|
+
holdUntilCrawlEnd,
|
|
15462
|
+
include: Array.from(
|
|
15463
|
+
/* @__PURE__ */ new Set([
|
|
15464
|
+
...farmConfig.optimizeDeps?.include || [],
|
|
15465
|
+
...userConfig.optimizeDeps?.include || []
|
|
15466
|
+
])
|
|
15467
|
+
),
|
|
15468
|
+
exclude: Array.from(
|
|
15469
|
+
/* @__PURE__ */ new Set([
|
|
15470
|
+
...farmConfig.optimizeDeps?.exclude || [],
|
|
15471
|
+
...userConfig.optimizeDeps?.exclude || []
|
|
15472
|
+
])
|
|
15473
|
+
)
|
|
15474
|
+
},
|
|
15475
|
+
ssr: {
|
|
15476
|
+
...farmConfig.ssr,
|
|
15477
|
+
...userConfig.ssr,
|
|
15478
|
+
noExternal: mergeNoExternal(farmConfig.ssr?.noExternal, userConfig.ssr?.noExternal)
|
|
15479
|
+
}
|
|
15480
|
+
};
|
|
15481
|
+
}
|
|
15482
|
+
var import_node_path9, FARM_CLIENT_ENTRY_PATTERN, FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE;
|
|
15483
|
+
var init_vite_config = __esm({
|
|
15484
|
+
"src/server/vite-config.ts"() {
|
|
15485
|
+
"use strict";
|
|
15486
|
+
import_node_path9 = __toESM(require("path"));
|
|
15487
|
+
FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
|
|
15488
|
+
FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
|
|
15489
|
+
"react",
|
|
15490
|
+
"react-dom",
|
|
15491
|
+
"react-dom/client",
|
|
15492
|
+
"react/jsx-runtime",
|
|
15493
|
+
"react/jsx-dev-runtime",
|
|
15494
|
+
"@farm.js/core/client",
|
|
15495
|
+
"@farm.js/core/plugin/client",
|
|
15496
|
+
"@farm.js/core/deferred",
|
|
15497
|
+
"@farm.js/core/deployment",
|
|
15498
|
+
"@farm.js/core/i18n/client",
|
|
15499
|
+
"@farm.js/core/query/client",
|
|
15500
|
+
"@farm.js/core/server-fn/client",
|
|
15501
|
+
"@farm.js/core/server-query/client"
|
|
15502
|
+
];
|
|
15503
|
+
__name(createFarmClientOptimizeDepsEntries, "createFarmClientOptimizeDepsEntries");
|
|
15504
|
+
__name(createFarmClientOptimizeDepsConfig, "createFarmClientOptimizeDepsConfig");
|
|
15505
|
+
__name(createFarmSourceAlias, "createFarmSourceAlias");
|
|
15506
|
+
__name(mergeNoExternal, "mergeNoExternal");
|
|
15507
|
+
__name(mergeAlias, "mergeAlias");
|
|
15508
|
+
__name(mergeFarmViteConfig, "mergeFarmViteConfig");
|
|
15509
|
+
}
|
|
15510
|
+
});
|
|
15511
|
+
|
|
15245
15512
|
// src/default-styles.ts
|
|
15246
15513
|
var defaultGlobalCSS;
|
|
15247
15514
|
var init_default_styles = __esm({
|
|
@@ -15649,12 +15916,12 @@ var init_module = __esm({
|
|
|
15649
15916
|
function isMiddlewareResponse(value) {
|
|
15650
15917
|
return value instanceof Response;
|
|
15651
15918
|
}
|
|
15652
|
-
var fs4,
|
|
15919
|
+
var fs4, path20, _MiddlewareManager, MiddlewareManager;
|
|
15653
15920
|
var init_manager = __esm({
|
|
15654
15921
|
"src/middleware/manager.ts"() {
|
|
15655
15922
|
"use strict";
|
|
15656
15923
|
fs4 = __toESM(require("fs"));
|
|
15657
|
-
|
|
15924
|
+
path20 = __toESM(require("path"));
|
|
15658
15925
|
init_context();
|
|
15659
15926
|
init_module();
|
|
15660
15927
|
init_utils();
|
|
@@ -15734,8 +16001,8 @@ var init_manager = __esm({
|
|
|
15734
16001
|
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
15735
16002
|
for (const entry of entries) {
|
|
15736
16003
|
if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
15737
|
-
const subPath =
|
|
15738
|
-
const subRoutePath =
|
|
16004
|
+
const subPath = path20.join(dir, entry.name);
|
|
16005
|
+
const subRoutePath = path20.posix.join(routePath, entry.name);
|
|
15739
16006
|
await this.discoverInDirectory(subPath, subRoutePath, discovered);
|
|
15740
16007
|
}
|
|
15741
16008
|
}
|
|
@@ -15746,7 +16013,7 @@ var init_manager = __esm({
|
|
|
15746
16013
|
findMiddlewareFile(dir) {
|
|
15747
16014
|
const extensions = [".ts", ".tsx", ".js", ".jsx"];
|
|
15748
16015
|
for (const ext of extensions) {
|
|
15749
|
-
const filePath =
|
|
16016
|
+
const filePath = path20.join(dir, `middleware${ext}`);
|
|
15750
16017
|
if (fs4.existsSync(filePath)) {
|
|
15751
16018
|
return filePath;
|
|
15752
16019
|
}
|
|
@@ -16374,12 +16641,12 @@ function createRoutePattern(route) {
|
|
|
16374
16641
|
}).join("/");
|
|
16375
16642
|
}
|
|
16376
16643
|
async function generateRouteTypes(options) {
|
|
16377
|
-
const root =
|
|
16644
|
+
const root = path21.resolve(options.root);
|
|
16378
16645
|
const srcDir = options.srcDir || "src";
|
|
16379
16646
|
const outFile = options.outFile || DEFAULT_OUT_FILE;
|
|
16380
|
-
const outPath =
|
|
16647
|
+
const outPath = path21.isAbsolute(outFile) ? outFile : path21.join(root, srcDir, outFile);
|
|
16381
16648
|
const content = await createRouteTypeDeclarations(options, outPath);
|
|
16382
|
-
fs5.mkdirSync(
|
|
16649
|
+
fs5.mkdirSync(path21.dirname(outPath), { recursive: true });
|
|
16383
16650
|
writeFileIfChanged(outPath, content);
|
|
16384
16651
|
return outPath;
|
|
16385
16652
|
}
|
|
@@ -16390,7 +16657,7 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
16390
16657
|
const routeModulePatterns = /* @__PURE__ */ new Set();
|
|
16391
16658
|
const glob = await import("fast-glob");
|
|
16392
16659
|
for (const source of sourceRoots) {
|
|
16393
|
-
const appDir =
|
|
16660
|
+
const appDir = path21.join(source.root, source.srcDir, "app");
|
|
16394
16661
|
if (fs5.existsSync(appDir)) {
|
|
16395
16662
|
const routeModuleFiles = await glob.default(
|
|
16396
16663
|
"**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
|
|
@@ -16427,7 +16694,7 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
16427
16694
|
const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
|
|
16428
16695
|
const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
|
|
16429
16696
|
const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
|
|
16430
|
-
const routeTypesImportPath = `./${
|
|
16697
|
+
const routeTypesImportPath = `./${path21.basename(outPath).replace(/\.d\.ts$/, "")}`;
|
|
16431
16698
|
const linkAugmentationBlock = suppressLintOnLink ? "" : `
|
|
16432
16699
|
declare module "@farm.js/core/client" {
|
|
16433
16700
|
interface LinkDefaultRoute {
|
|
@@ -16474,11 +16741,11 @@ ${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentati
|
|
|
16474
16741
|
`;
|
|
16475
16742
|
return content;
|
|
16476
16743
|
}
|
|
16477
|
-
var
|
|
16744
|
+
var path21, fs5, DEFAULT_OUT_FILE;
|
|
16478
16745
|
var init_generate_route_types = __esm({
|
|
16479
16746
|
"src/routing/generate-route-types.ts"() {
|
|
16480
16747
|
"use strict";
|
|
16481
|
-
|
|
16748
|
+
path21 = __toESM(require("path"));
|
|
16482
16749
|
fs5 = __toESM(require("fs"));
|
|
16483
16750
|
init_utils();
|
|
16484
16751
|
init_route_slots();
|
|
@@ -16498,17 +16765,17 @@ var init_generate_route_types = __esm({
|
|
|
16498
16765
|
|
|
16499
16766
|
// src/env-types.ts
|
|
16500
16767
|
async function generateEnvTypes(options) {
|
|
16501
|
-
const root =
|
|
16768
|
+
const root = path22.resolve(options.root);
|
|
16502
16769
|
const srcDir = options.srcDir || "src";
|
|
16503
16770
|
const outFile = options.outFile || DEFAULT_OUT_FILE2;
|
|
16504
|
-
const outPath =
|
|
16771
|
+
const outPath = path22.isAbsolute(outFile) ? outFile : path22.join(root, srcDir, outFile);
|
|
16505
16772
|
const content = createEnvTypeDeclarations(options, outPath);
|
|
16506
|
-
fs6.mkdirSync(
|
|
16773
|
+
fs6.mkdirSync(path22.dirname(outPath), { recursive: true });
|
|
16507
16774
|
writeFileIfChanged(outPath, content);
|
|
16508
16775
|
return outPath;
|
|
16509
16776
|
}
|
|
16510
16777
|
function createEnvTypeDeclarations(options, outPath) {
|
|
16511
|
-
const root =
|
|
16778
|
+
const root = path22.resolve(options.root);
|
|
16512
16779
|
const configPath = findConfigPath(root, options.configPath);
|
|
16513
16780
|
const configPaths = [
|
|
16514
16781
|
...(options.layerConfigPaths ?? []).filter((value) => fs6.existsSync(value)),
|
|
@@ -16571,11 +16838,11 @@ export {};
|
|
|
16571
16838
|
}
|
|
16572
16839
|
function findConfigPath(root, configPath) {
|
|
16573
16840
|
if (configPath) {
|
|
16574
|
-
const resolvedPath =
|
|
16841
|
+
const resolvedPath = path22.isAbsolute(configPath) ? configPath : path22.join(root, configPath);
|
|
16575
16842
|
return fs6.existsSync(resolvedPath) ? resolvedPath : null;
|
|
16576
16843
|
}
|
|
16577
16844
|
for (const filename of CONFIG_FILENAMES2) {
|
|
16578
|
-
const resolvedPath =
|
|
16845
|
+
const resolvedPath = path22.join(root, filename);
|
|
16579
16846
|
if (fs6.existsSync(resolvedPath)) {
|
|
16580
16847
|
return resolvedPath;
|
|
16581
16848
|
}
|
|
@@ -16636,15 +16903,15 @@ export {};
|
|
|
16636
16903
|
`;
|
|
16637
16904
|
}
|
|
16638
16905
|
function toTypeImportPath(outPath, targetPath) {
|
|
16639
|
-
const relativePath2 =
|
|
16906
|
+
const relativePath2 = path22.relative(path22.dirname(outPath), targetPath).replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
|
|
16640
16907
|
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
16641
16908
|
}
|
|
16642
|
-
var fs6,
|
|
16909
|
+
var fs6, path22, DEFAULT_OUT_FILE2, CONFIG_FILENAMES2;
|
|
16643
16910
|
var init_env_types = __esm({
|
|
16644
16911
|
"src/env-types.ts"() {
|
|
16645
16912
|
"use strict";
|
|
16646
16913
|
fs6 = __toESM(require("fs"));
|
|
16647
|
-
|
|
16914
|
+
path22 = __toESM(require("path"));
|
|
16648
16915
|
init_write_file_if_changed();
|
|
16649
16916
|
DEFAULT_OUT_FILE2 = "farm-env.d.ts";
|
|
16650
16917
|
CONFIG_FILENAMES2 = [
|
|
@@ -16677,8 +16944,8 @@ var init_env_types = __esm({
|
|
|
16677
16944
|
|
|
16678
16945
|
// src/image-types.ts
|
|
16679
16946
|
function generateFarmImageTypes(options) {
|
|
16680
|
-
const outputPath = options.outFile ?
|
|
16681
|
-
(0, import_node_fs7.mkdirSync)(
|
|
16947
|
+
const outputPath = options.outFile ? import_node_path10.default.resolve(options.root, options.outFile) : import_node_path10.default.join(options.root, options.srcDir || "src", "farm-images.d.ts");
|
|
16948
|
+
(0, import_node_fs7.mkdirSync)(import_node_path10.default.dirname(outputPath), { recursive: true });
|
|
16682
16949
|
writeFileIfChanged(outputPath, createFarmImageTypeDeclarations());
|
|
16683
16950
|
return outputPath;
|
|
16684
16951
|
}
|
|
@@ -16702,12 +16969,12 @@ declare module "*?url" {
|
|
|
16702
16969
|
}
|
|
16703
16970
|
`;
|
|
16704
16971
|
}
|
|
16705
|
-
var import_node_fs7,
|
|
16972
|
+
var import_node_fs7, import_node_path10, FARM_STATIC_IMAGE_EXTENSIONS;
|
|
16706
16973
|
var init_image_types = __esm({
|
|
16707
16974
|
"src/image-types.ts"() {
|
|
16708
16975
|
"use strict";
|
|
16709
16976
|
import_node_fs7 = require("fs");
|
|
16710
|
-
|
|
16977
|
+
import_node_path10 = __toESM(require("path"));
|
|
16711
16978
|
init_write_file_if_changed();
|
|
16712
16979
|
FARM_STATIC_IMAGE_EXTENSIONS = ["avif", "gif", "jpeg", "jpg", "png", "webp"];
|
|
16713
16980
|
__name(generateFarmImageTypes, "generateFarmImageTypes");
|
|
@@ -16719,9 +16986,9 @@ var init_image_types = __esm({
|
|
|
16719
16986
|
async function generateFarmI18nTypes(options) {
|
|
16720
16987
|
if (!options.config.enabled) return void 0;
|
|
16721
16988
|
const { signatures } = await readFarmI18nCatalogs(options.config);
|
|
16722
|
-
const outFile = options.outFile ? (0,
|
|
16989
|
+
const outFile = options.outFile ? (0, import_node_path11.resolve)(options.root, options.outFile) : (0, import_node_path11.join)((0, import_node_path11.resolve)(options.root), options.srcDir || "src", "farm-i18n.d.ts");
|
|
16723
16990
|
const content = renderFarmI18nTypes(options.config.locales, signatures);
|
|
16724
|
-
(0, import_node_fs8.mkdirSync)((0,
|
|
16991
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path11.dirname)(outFile), { recursive: true });
|
|
16725
16992
|
writeFileIfChanged(outFile, content);
|
|
16726
16993
|
return outFile;
|
|
16727
16994
|
}
|
|
@@ -16762,12 +17029,12 @@ function argumentType(kind) {
|
|
|
16762
17029
|
return "string";
|
|
16763
17030
|
}
|
|
16764
17031
|
}
|
|
16765
|
-
var import_node_fs8,
|
|
17032
|
+
var import_node_fs8, import_node_path11;
|
|
16766
17033
|
var init_type_generator2 = __esm({
|
|
16767
17034
|
"src/i18n/type-generator.ts"() {
|
|
16768
17035
|
"use strict";
|
|
16769
17036
|
import_node_fs8 = require("fs");
|
|
16770
|
-
|
|
17037
|
+
import_node_path11 = require("path");
|
|
16771
17038
|
init_catalog();
|
|
16772
17039
|
init_write_file_if_changed();
|
|
16773
17040
|
__name(generateFarmI18nTypes, "generateFarmI18nTypes");
|
|
@@ -16992,7 +17259,7 @@ var init_type_artifacts = __esm({
|
|
|
16992
17259
|
var version;
|
|
16993
17260
|
var init_package = __esm({
|
|
16994
17261
|
"package.json"() {
|
|
16995
|
-
version = "0.1.0-beta.
|
|
17262
|
+
version = "0.1.0-beta.17";
|
|
16996
17263
|
}
|
|
16997
17264
|
});
|
|
16998
17265
|
|
|
@@ -17172,12 +17439,12 @@ async function createBlurDataURL(bytes) {
|
|
|
17172
17439
|
return void 0;
|
|
17173
17440
|
}
|
|
17174
17441
|
}
|
|
17175
|
-
var import_promises7,
|
|
17442
|
+
var import_promises7, import_node_path12, import_image_size2, FARM_IMAGE_ID_PREFIX, STATIC_IMAGE_RE, SCRIPT_IMPORTER_RE;
|
|
17176
17443
|
var init_image_vite = __esm({
|
|
17177
17444
|
"src/image-vite.ts"() {
|
|
17178
17445
|
"use strict";
|
|
17179
17446
|
import_promises7 = require("fs/promises");
|
|
17180
|
-
|
|
17447
|
+
import_node_path12 = __toESM(require("path"));
|
|
17181
17448
|
import_image_size2 = require("image-size");
|
|
17182
17449
|
FARM_IMAGE_ID_PREFIX = "\0farm:image:";
|
|
17183
17450
|
STATIC_IMAGE_RE = /\.(?:avif|gif|jpe?g|png|webp)$/i;
|
|
@@ -17620,106 +17887,6 @@ var init_image_server = __esm({
|
|
|
17620
17887
|
}
|
|
17621
17888
|
});
|
|
17622
17889
|
|
|
17623
|
-
// src/server/vite-config.ts
|
|
17624
|
-
function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
|
|
17625
|
-
const resolvedProjectRoot = import_node_path12.default.resolve(projectRoot);
|
|
17626
|
-
return appDirectories.map((appDirectory) => {
|
|
17627
|
-
const relativeAppDirectory = import_node_path12.default.relative(resolvedProjectRoot, import_node_path12.default.resolve(appDirectory)).replace(/\\/g, "/");
|
|
17628
|
-
const prefix = relativeAppDirectory || ".";
|
|
17629
|
-
return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
|
|
17630
|
-
});
|
|
17631
|
-
}
|
|
17632
|
-
function createFarmClientOptimizeDepsConfig(entries) {
|
|
17633
|
-
return {
|
|
17634
|
-
// Keep normal application dependency discovery for CJS-only packages, but
|
|
17635
|
-
// seed every Farm browser runtime so React is present in the first crawl.
|
|
17636
|
-
noDiscovery: false,
|
|
17637
|
-
// Waiting for the crawl avoids serving a partial optimizer generation and
|
|
17638
|
-
// then changing browser hashes while hydration is already in progress.
|
|
17639
|
-
holdUntilCrawlEnd: true,
|
|
17640
|
-
include: [...FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE],
|
|
17641
|
-
// Farm's HTML boots through a virtual module and imports route UI lazily.
|
|
17642
|
-
// Explicit entries let Vite finish that crawl before a navigation can
|
|
17643
|
-
// rotate the optimizer hash underneath a hydrated React runtime.
|
|
17644
|
-
...entries?.length ? { entries: [...entries] } : {}
|
|
17645
|
-
};
|
|
17646
|
-
}
|
|
17647
|
-
function mergeNoExternal(farmValue, userValue) {
|
|
17648
|
-
if (farmValue === true || userValue === true) return true;
|
|
17649
|
-
const normalize = /* @__PURE__ */ __name((value) => value == null || value === true ? [] : Array.isArray(value) ? value : [value], "normalize");
|
|
17650
|
-
return Array.from(/* @__PURE__ */ new Set([...normalize(farmValue), ...normalize(userValue)]));
|
|
17651
|
-
}
|
|
17652
|
-
function mergeFarmViteConfig(farmConfig, userConfig = {}) {
|
|
17653
|
-
const noDiscovery = userConfig.optimizeDeps?.noDiscovery ?? farmConfig.optimizeDeps?.noDiscovery;
|
|
17654
|
-
const holdUntilCrawlEnd = userConfig.optimizeDeps?.holdUntilCrawlEnd ?? (userConfig.optimizeDeps?.noDiscovery === true ? false : farmConfig.optimizeDeps?.holdUntilCrawlEnd);
|
|
17655
|
-
return {
|
|
17656
|
-
...farmConfig,
|
|
17657
|
-
...userConfig,
|
|
17658
|
-
plugins: [...farmConfig.plugins || [], ...userConfig.plugins || []],
|
|
17659
|
-
server: {
|
|
17660
|
-
...farmConfig.server,
|
|
17661
|
-
...userConfig.server
|
|
17662
|
-
},
|
|
17663
|
-
resolve: {
|
|
17664
|
-
...farmConfig.resolve,
|
|
17665
|
-
...userConfig.resolve,
|
|
17666
|
-
dedupe: Array.from(
|
|
17667
|
-
/* @__PURE__ */ new Set([...farmConfig.resolve?.dedupe || [], ...userConfig.resolve?.dedupe || []])
|
|
17668
|
-
)
|
|
17669
|
-
},
|
|
17670
|
-
optimizeDeps: {
|
|
17671
|
-
...farmConfig.optimizeDeps,
|
|
17672
|
-
...userConfig.optimizeDeps,
|
|
17673
|
-
noDiscovery,
|
|
17674
|
-
holdUntilCrawlEnd,
|
|
17675
|
-
include: Array.from(
|
|
17676
|
-
/* @__PURE__ */ new Set([
|
|
17677
|
-
...farmConfig.optimizeDeps?.include || [],
|
|
17678
|
-
...userConfig.optimizeDeps?.include || []
|
|
17679
|
-
])
|
|
17680
|
-
),
|
|
17681
|
-
exclude: Array.from(
|
|
17682
|
-
/* @__PURE__ */ new Set([
|
|
17683
|
-
...farmConfig.optimizeDeps?.exclude || [],
|
|
17684
|
-
...userConfig.optimizeDeps?.exclude || []
|
|
17685
|
-
])
|
|
17686
|
-
)
|
|
17687
|
-
},
|
|
17688
|
-
ssr: {
|
|
17689
|
-
...farmConfig.ssr,
|
|
17690
|
-
...userConfig.ssr,
|
|
17691
|
-
noExternal: mergeNoExternal(farmConfig.ssr?.noExternal, userConfig.ssr?.noExternal)
|
|
17692
|
-
}
|
|
17693
|
-
};
|
|
17694
|
-
}
|
|
17695
|
-
var import_node_path12, FARM_CLIENT_ENTRY_PATTERN, FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE;
|
|
17696
|
-
var init_vite_config = __esm({
|
|
17697
|
-
"src/server/vite-config.ts"() {
|
|
17698
|
-
"use strict";
|
|
17699
|
-
import_node_path12 = __toESM(require("path"));
|
|
17700
|
-
FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
|
|
17701
|
-
FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
|
|
17702
|
-
"react",
|
|
17703
|
-
"react-dom",
|
|
17704
|
-
"react-dom/client",
|
|
17705
|
-
"react/jsx-runtime",
|
|
17706
|
-
"react/jsx-dev-runtime",
|
|
17707
|
-
"@farm.js/core/client",
|
|
17708
|
-
"@farm.js/core/plugin/client",
|
|
17709
|
-
"@farm.js/core/deferred",
|
|
17710
|
-
"@farm.js/core/deployment",
|
|
17711
|
-
"@farm.js/core/i18n/client",
|
|
17712
|
-
"@farm.js/core/query/client",
|
|
17713
|
-
"@farm.js/core/server-fn/client",
|
|
17714
|
-
"@farm.js/core/server-query/client"
|
|
17715
|
-
];
|
|
17716
|
-
__name(createFarmClientOptimizeDepsEntries, "createFarmClientOptimizeDepsEntries");
|
|
17717
|
-
__name(createFarmClientOptimizeDepsConfig, "createFarmClientOptimizeDepsConfig");
|
|
17718
|
-
__name(mergeNoExternal, "mergeNoExternal");
|
|
17719
|
-
__name(mergeFarmViteConfig, "mergeFarmViteConfig");
|
|
17720
|
-
}
|
|
17721
|
-
});
|
|
17722
|
-
|
|
17723
17890
|
// src/docs/pixel-border-css.ts
|
|
17724
17891
|
var farmDocsPixelBorderCss;
|
|
17725
17892
|
var init_pixel_border_css = __esm({
|
|
@@ -27836,7 +28003,7 @@ async function defineConfig2(config = {}) {
|
|
|
27836
28003
|
// Stub out problematic server-only modules during dev mode
|
|
27837
28004
|
alias: {
|
|
27838
28005
|
...getFarmLayerAliases(config.layers),
|
|
27839
|
-
|
|
28006
|
+
...createFarmSourceAlias(appRoot, config.srcDir),
|
|
27840
28007
|
// Nitro internals that should not be resolved in browser
|
|
27841
28008
|
"supports-color": "data:text/javascript,export default false; export const supportsColor = false; export const stdout = false; export const stderr = false;",
|
|
27842
28009
|
"@poppinss/dumper": "data:text/javascript,export default {};",
|
|
@@ -29645,6 +29812,7 @@ __name(withVite5TransformContext, "withVite5TransformContext");
|
|
|
29645
29812
|
|
|
29646
29813
|
// src/nitro/universal-build.ts
|
|
29647
29814
|
init_font_vite();
|
|
29815
|
+
init_vite_config();
|
|
29648
29816
|
var import_meta = {};
|
|
29649
29817
|
function preloadFarmNitroRuntime() {
|
|
29650
29818
|
return import("nitro").then(
|
|
@@ -32038,9 +32206,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
32038
32206
|
postcss: postcssConfigDir
|
|
32039
32207
|
} : void 0,
|
|
32040
32208
|
resolve: {
|
|
32041
|
-
alias:
|
|
32042
|
-
"@": import_path12.default.resolve(root, "src")
|
|
32043
|
-
},
|
|
32209
|
+
alias: createFarmSourceAlias(root, config.srcDir),
|
|
32044
32210
|
// Programmatic route wrappers are created inside @farm.js/core. Resolve
|
|
32045
32211
|
// their React imports from the application so React 18/19 elements and
|
|
32046
32212
|
// the selected server renderer always share the same runtime instance.
|
|
@@ -35698,6 +35864,9 @@ async function createProjectModuleServer(createViteServer, config, root) {
|
|
|
35698
35864
|
middlewareMode: true,
|
|
35699
35865
|
hmr: false
|
|
35700
35866
|
},
|
|
35867
|
+
resolve: {
|
|
35868
|
+
alias: createFarmSourceAlias(root, config.srcDir)
|
|
35869
|
+
},
|
|
35701
35870
|
optimizeDeps: {
|
|
35702
35871
|
noDiscovery: true
|
|
35703
35872
|
},
|