@farm.js/core 0.1.0-beta.14 → 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.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/route-manager.mjs +2 -2
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api/runtime.mjs +1 -1
- package/dist/api.cjs +18 -10
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/api.mjs +3 -3
- 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-VUL55IAX.mjs → chunk-2FLBZFPG.mjs} +19 -19
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/{chunk-B232I2GP.mjs → chunk-3HIVDX7J.mjs} +12 -1
- package/dist/chunk-3HIVDX7J.mjs.map +1 -0
- package/dist/{chunk-JDEOUK5V.mjs → chunk-6YXKHAFU.mjs} +3 -3
- package/dist/{chunk-Z5CQMP54.mjs → chunk-ARRYKOI5.mjs} +2 -2
- package/dist/{chunk-KLA67WKG.mjs → chunk-B3FFOIWS.mjs} +2 -2
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-PFE6GMNE.mjs → chunk-HMRFYJK6.mjs} +19 -11
- package/dist/chunk-HMRFYJK6.mjs.map +1 -0
- package/dist/{chunk-OPHK6OJN.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-32W4QEJP.mjs → chunk-KFTGPFRD.mjs} +1 -1
- package/dist/chunk-KFTGPFRD.mjs.map +1 -0
- package/dist/{chunk-L2PE36GQ.mjs → chunk-PZXBQKCH.mjs} +15 -6
- 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-PNFQQSRA.mjs → chunk-T2M5QANG.mjs} +143 -41
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-WDU6QXNK.mjs → chunk-UCYWGN2P.mjs} +1 -1
- package/dist/chunk-UCYWGN2P.mjs.map +1 -0
- package/dist/{chunk-65A7QIKI.mjs → chunk-UMVLB3PN.mjs} +3 -3
- package/dist/chunk-UMVLB3PN.mjs.map +1 -0
- package/dist/{chunk-ARCGE2VT.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-ARCGE2VT.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
- package/dist/{chunk-VY2UYN5R.mjs → chunk-VPCFICID.mjs} +82 -3
- package/dist/chunk-VPCFICID.mjs.map +1 -0
- package/dist/{chunk-H3TE3LOV.mjs → chunk-XMFTIVJH.mjs} +2 -2
- package/dist/{chunk-UB5UOSHB.mjs → chunk-ZVMV3THA.mjs} +71 -2
- package/dist/chunk-ZVMV3THA.mjs.map +1 -0
- 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.cjs.map +1 -1
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/client.mjs +3 -3
- 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.cjs +12 -0
- package/dist/deployment.cjs.map +1 -1
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/deployment.mjs +3 -1
- package/dist/{devtools-GAZ7F3KL.mjs → devtools-K2ERKGNI.mjs} +5 -5
- 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 +5 -5
- 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 +598 -109
- 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 +45 -29
- 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 +438 -176
- 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 +13 -13
- 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 +4 -4
- 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.cjs.map +1 -1
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/navigation.mjs +3 -3
- 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 +247 -28
- 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 +10 -10
- 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.cjs +23 -1
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-action-security.mjs +1 -1
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.cjs +140 -3
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-fn.mjs +14 -3
- 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.cjs +99 -1
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +403 -33
- 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 +14 -14
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/testing.mjs +3 -3
- 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 +255 -30
- 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 +10 -10
- 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-32W4QEJP.mjs.map +0 -1
- package/dist/chunk-65A7QIKI.mjs.map +0 -1
- package/dist/chunk-B232I2GP.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-L2PE36GQ.mjs.map +0 -1
- package/dist/chunk-PFE6GMNE.mjs.map +0 -1
- package/dist/chunk-PNFQQSRA.mjs.map +0 -1
- package/dist/chunk-UB5UOSHB.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- package/dist/chunk-VUL55IAX.mjs.map +0 -1
- package/dist/chunk-VY2UYN5R.mjs.map +0 -1
- package/dist/chunk-WDU6QXNK.mjs.map +0 -1
- /package/dist/{chunk-JDEOUK5V.mjs.map → chunk-6YXKHAFU.mjs.map} +0 -0
- /package/dist/{chunk-Z5CQMP54.mjs.map → chunk-ARRYKOI5.mjs.map} +0 -0
- /package/dist/{chunk-KLA67WKG.mjs.map → chunk-B3FFOIWS.mjs.map} +0 -0
- /package/dist/{chunk-OPHK6OJN.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{chunk-H3TE3LOV.mjs.map → chunk-XMFTIVJH.mjs.map} +0 -0
- /package/dist/{devtools-GAZ7F3KL.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
|
@@ -4303,6 +4303,13 @@ var init_cache_invalidation = __esm({
|
|
|
4303
4303
|
}
|
|
4304
4304
|
});
|
|
4305
4305
|
|
|
4306
|
+
// src/server-fn-error.ts
|
|
4307
|
+
var init_server_fn_error = __esm({
|
|
4308
|
+
"src/server-fn-error.ts"() {
|
|
4309
|
+
"use strict";
|
|
4310
|
+
}
|
|
4311
|
+
});
|
|
4312
|
+
|
|
4306
4313
|
// src/server-action-security.ts
|
|
4307
4314
|
function resolveServerActionsConfig(config) {
|
|
4308
4315
|
const allowedOrigins = (config?.allowedOrigins ?? []).map(normalizeAllowedOriginPattern);
|
|
@@ -4396,6 +4403,7 @@ var init_server_action_security = __esm({
|
|
|
4396
4403
|
"use strict";
|
|
4397
4404
|
import_node_async_hooks = require("async_hooks");
|
|
4398
4405
|
init_cache_invalidation();
|
|
4406
|
+
init_server_fn_error();
|
|
4399
4407
|
DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1e6;
|
|
4400
4408
|
SERVER_ACTION_STORAGE_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionStorage");
|
|
4401
4409
|
__name(resolveServerActionsConfig, "resolveServerActionsConfig");
|
|
@@ -4865,6 +4873,15 @@ var init_layers = __esm({
|
|
|
4865
4873
|
});
|
|
4866
4874
|
|
|
4867
4875
|
// src/deployment.ts
|
|
4876
|
+
function getFarmPresetRuntime(preset) {
|
|
4877
|
+
if (preset === "cloudflare" || preset === "cloudflare-pages" || preset === "cloudflare-module" || preset === "netlify-edge" || preset === "vercel-edge" || preset === "deno") {
|
|
4878
|
+
return "edge";
|
|
4879
|
+
}
|
|
4880
|
+
if (preset === "node-server" || preset === "vercel" || preset === "netlify" || preset === "aws-lambda" || preset === "azure" || preset === "firebase" || preset === "bun" || preset === "self-host" || preset === "farm") {
|
|
4881
|
+
return "node";
|
|
4882
|
+
}
|
|
4883
|
+
return "unknown";
|
|
4884
|
+
}
|
|
4868
4885
|
function normalizeFarmDeploymentId(value) {
|
|
4869
4886
|
if (typeof value !== "string" || value.trim() === "") {
|
|
4870
4887
|
throw new TypeError("Farm deploymentId must be a non-empty string");
|
|
@@ -4940,6 +4957,7 @@ var init_deployment = __esm({
|
|
|
4940
4957
|
FARM_DEPLOYMENT_COOKIE = "__farm_deployment";
|
|
4941
4958
|
FARM_DEPLOYMENT_MISMATCH_CODE = "FARM_DEPLOYMENT_MISMATCH";
|
|
4942
4959
|
FARM_DEPLOYMENT_MISMATCH_STATUS = 409;
|
|
4960
|
+
__name(getFarmPresetRuntime, "getFarmPresetRuntime");
|
|
4943
4961
|
__name(normalizeFarmDeploymentId, "normalizeFarmDeploymentId");
|
|
4944
4962
|
__name(getFarmRequestDeploymentId, "getFarmRequestDeploymentId");
|
|
4945
4963
|
__name(getFarmDeploymentMismatch, "getFarmDeploymentMismatch");
|
|
@@ -5388,6 +5406,143 @@ var init_preload = __esm({
|
|
|
5388
5406
|
}
|
|
5389
5407
|
});
|
|
5390
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
|
+
|
|
5391
5546
|
// src/config-entry.ts
|
|
5392
5547
|
var init_config_entry = __esm({
|
|
5393
5548
|
"src/config-entry.ts"() {
|
|
@@ -5649,6 +5804,8 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5649
5804
|
const routeRules = normalizeRouteRules(userConfig.routeRules);
|
|
5650
5805
|
const routeRuleRedirects = routeRulesToRedirects(routeRules);
|
|
5651
5806
|
const routeRuleHeaders = routeRulesToHeaders(routeRules);
|
|
5807
|
+
const security = resolveFarmSecurityConfig(userConfig.security);
|
|
5808
|
+
const securityHeader = getFarmSecurityHeader(security);
|
|
5652
5809
|
const deploy = resolveDeployConfig(userConfig);
|
|
5653
5810
|
const root = userConfig.root || process.cwd();
|
|
5654
5811
|
const srcDir = userConfig.srcDir || "src";
|
|
@@ -5704,7 +5861,11 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5704
5861
|
trailingSlash: userConfig.trailingSlash ?? false,
|
|
5705
5862
|
redirects: /* @__PURE__ */ __name(() => [...redirects, ...routeRuleRedirects], "redirects"),
|
|
5706
5863
|
rewrites: /* @__PURE__ */ __name(() => rewrites, "rewrites"),
|
|
5707
|
-
headers: /* @__PURE__ */ __name(() => [
|
|
5864
|
+
headers: /* @__PURE__ */ __name(() => [
|
|
5865
|
+
...headers,
|
|
5866
|
+
...routeRuleHeaders,
|
|
5867
|
+
...securityHeader ? [{ source: "/*", headers: [securityHeader] }] : []
|
|
5868
|
+
], "headers"),
|
|
5708
5869
|
routeRules,
|
|
5709
5870
|
images: resolveFarmImageConfig(userConfig.images),
|
|
5710
5871
|
performance: resolveFarmPerformanceConfig(userConfig.performance),
|
|
@@ -5723,6 +5884,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
5723
5884
|
notFound: userConfig.notFound || {},
|
|
5724
5885
|
context: userConfig.context || (() => void 0),
|
|
5725
5886
|
serverActions: resolveServerActionsConfig(userConfig.serverActions),
|
|
5887
|
+
security,
|
|
5726
5888
|
deploymentId,
|
|
5727
5889
|
output: userConfig.output || "standalone",
|
|
5728
5890
|
distDir: userConfig.distDir || ".farm",
|
|
@@ -5802,6 +5964,7 @@ var init_config2 = __esm({
|
|
|
5802
5964
|
init_config();
|
|
5803
5965
|
init_auth_config();
|
|
5804
5966
|
init_preload();
|
|
5967
|
+
init_security();
|
|
5805
5968
|
init_config_entry();
|
|
5806
5969
|
FARM_RESOLVED_CUSTOM_CONTEXT = /* @__PURE__ */ Symbol.for("farm.resolvedCustomContext");
|
|
5807
5970
|
__name(hasCustomFarmRouteContext, "hasCustomFarmRouteContext");
|
|
@@ -13522,6 +13685,7 @@ var init_app = __esm({
|
|
|
13522
13685
|
init_cache();
|
|
13523
13686
|
init_auth_config();
|
|
13524
13687
|
init_preload();
|
|
13688
|
+
init_security();
|
|
13525
13689
|
defaultDocsConfig = {
|
|
13526
13690
|
enabled: false,
|
|
13527
13691
|
entry: "/docs",
|
|
@@ -13586,6 +13750,7 @@ var init_app = __esm({
|
|
|
13586
13750
|
routeRules: normalizeRouteRules(config.routeRules),
|
|
13587
13751
|
context: config.context || (() => void 0),
|
|
13588
13752
|
serverActions: resolveServerActionsConfig(config.serverActions),
|
|
13753
|
+
security: resolveFarmSecurityConfig(config.security),
|
|
13589
13754
|
images: resolveFarmImageConfig(config.images),
|
|
13590
13755
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
13591
13756
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|
|
@@ -15224,6 +15389,126 @@ var init_fonts = __esm({
|
|
|
15224
15389
|
}
|
|
15225
15390
|
});
|
|
15226
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
|
+
|
|
15227
15512
|
// src/default-styles.ts
|
|
15228
15513
|
var defaultGlobalCSS;
|
|
15229
15514
|
var init_default_styles = __esm({
|
|
@@ -15631,12 +15916,12 @@ var init_module = __esm({
|
|
|
15631
15916
|
function isMiddlewareResponse(value) {
|
|
15632
15917
|
return value instanceof Response;
|
|
15633
15918
|
}
|
|
15634
|
-
var fs4,
|
|
15919
|
+
var fs4, path20, _MiddlewareManager, MiddlewareManager;
|
|
15635
15920
|
var init_manager = __esm({
|
|
15636
15921
|
"src/middleware/manager.ts"() {
|
|
15637
15922
|
"use strict";
|
|
15638
15923
|
fs4 = __toESM(require("fs"));
|
|
15639
|
-
|
|
15924
|
+
path20 = __toESM(require("path"));
|
|
15640
15925
|
init_context();
|
|
15641
15926
|
init_module();
|
|
15642
15927
|
init_utils();
|
|
@@ -15716,8 +16001,8 @@ var init_manager = __esm({
|
|
|
15716
16001
|
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
15717
16002
|
for (const entry of entries) {
|
|
15718
16003
|
if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
15719
|
-
const subPath =
|
|
15720
|
-
const subRoutePath =
|
|
16004
|
+
const subPath = path20.join(dir, entry.name);
|
|
16005
|
+
const subRoutePath = path20.posix.join(routePath, entry.name);
|
|
15721
16006
|
await this.discoverInDirectory(subPath, subRoutePath, discovered);
|
|
15722
16007
|
}
|
|
15723
16008
|
}
|
|
@@ -15728,7 +16013,7 @@ var init_manager = __esm({
|
|
|
15728
16013
|
findMiddlewareFile(dir) {
|
|
15729
16014
|
const extensions = [".ts", ".tsx", ".js", ".jsx"];
|
|
15730
16015
|
for (const ext of extensions) {
|
|
15731
|
-
const filePath =
|
|
16016
|
+
const filePath = path20.join(dir, `middleware${ext}`);
|
|
15732
16017
|
if (fs4.existsSync(filePath)) {
|
|
15733
16018
|
return filePath;
|
|
15734
16019
|
}
|
|
@@ -16340,6 +16625,13 @@ function routePatternToTsTypeLiterals(pattern) {
|
|
|
16340
16625
|
function routePatternToRouteLiteral(pattern) {
|
|
16341
16626
|
return JSON.stringify(pattern);
|
|
16342
16627
|
}
|
|
16628
|
+
function renderTypeUnion(values) {
|
|
16629
|
+
return values.length <= 1 ? values[0] || "never" : `
|
|
16630
|
+
| ${values.join("\n | ")}`;
|
|
16631
|
+
}
|
|
16632
|
+
function renderTypeAlias(name, value) {
|
|
16633
|
+
return `export type ${name} =${value.startsWith("\n") ? "" : " "}${value};`;
|
|
16634
|
+
}
|
|
16343
16635
|
function createRoutePattern(route) {
|
|
16344
16636
|
if (route.segments.length === 0) return "/";
|
|
16345
16637
|
return "/" + route.segments.map((seg) => {
|
|
@@ -16349,12 +16641,12 @@ function createRoutePattern(route) {
|
|
|
16349
16641
|
}).join("/");
|
|
16350
16642
|
}
|
|
16351
16643
|
async function generateRouteTypes(options) {
|
|
16352
|
-
const root =
|
|
16644
|
+
const root = path21.resolve(options.root);
|
|
16353
16645
|
const srcDir = options.srcDir || "src";
|
|
16354
16646
|
const outFile = options.outFile || DEFAULT_OUT_FILE;
|
|
16355
|
-
const outPath =
|
|
16647
|
+
const outPath = path21.isAbsolute(outFile) ? outFile : path21.join(root, srcDir, outFile);
|
|
16356
16648
|
const content = await createRouteTypeDeclarations(options, outPath);
|
|
16357
|
-
fs5.mkdirSync(
|
|
16649
|
+
fs5.mkdirSync(path21.dirname(outPath), { recursive: true });
|
|
16358
16650
|
writeFileIfChanged(outPath, content);
|
|
16359
16651
|
return outPath;
|
|
16360
16652
|
}
|
|
@@ -16365,7 +16657,7 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
16365
16657
|
const routeModulePatterns = /* @__PURE__ */ new Set();
|
|
16366
16658
|
const glob = await import("fast-glob");
|
|
16367
16659
|
for (const source of sourceRoots) {
|
|
16368
|
-
const appDir =
|
|
16660
|
+
const appDir = path21.join(source.root, source.srcDir, "app");
|
|
16369
16661
|
if (fs5.existsSync(appDir)) {
|
|
16370
16662
|
const routeModuleFiles = await glob.default(
|
|
16371
16663
|
"**/{page,layout,loading,error}.{ts,tsx,js,jsx,md,mdx}",
|
|
@@ -16399,10 +16691,10 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
16399
16691
|
const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
|
|
16400
16692
|
const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
|
|
16401
16693
|
const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
|
|
16402
|
-
const routePathType = suppressLintOnLink ? "string" : typeLiterals
|
|
16403
|
-
const routePatternType = suppressLintOnLink ? "string" : patternLiterals
|
|
16404
|
-
const routeModulePatternType = routeModulePatternLiterals
|
|
16405
|
-
const routeTypesImportPath = `./${
|
|
16694
|
+
const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
|
|
16695
|
+
const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
|
|
16696
|
+
const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
|
|
16697
|
+
const routeTypesImportPath = `./${path21.basename(outPath).replace(/\.d\.ts$/, "")}`;
|
|
16406
16698
|
const linkAugmentationBlock = suppressLintOnLink ? "" : `
|
|
16407
16699
|
declare module "@farm.js/core/client" {
|
|
16408
16700
|
interface LinkDefaultRoute {
|
|
@@ -16443,17 +16735,17 @@ declare global {
|
|
|
16443
16735
|
* Regenerated on dev start and when routes change.
|
|
16444
16736
|
* Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
|
|
16445
16737
|
*/
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
16738
|
+
${renderTypeAlias("RoutePath", routePathType)}
|
|
16739
|
+
${renderTypeAlias("RoutePattern", routePatternType)}
|
|
16740
|
+
${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentationBlock}${routeModuleAugmentationBlock}
|
|
16449
16741
|
`;
|
|
16450
16742
|
return content;
|
|
16451
16743
|
}
|
|
16452
|
-
var
|
|
16744
|
+
var path21, fs5, DEFAULT_OUT_FILE;
|
|
16453
16745
|
var init_generate_route_types = __esm({
|
|
16454
16746
|
"src/routing/generate-route-types.ts"() {
|
|
16455
16747
|
"use strict";
|
|
16456
|
-
|
|
16748
|
+
path21 = __toESM(require("path"));
|
|
16457
16749
|
fs5 = __toESM(require("fs"));
|
|
16458
16750
|
init_utils();
|
|
16459
16751
|
init_route_slots();
|
|
@@ -16462,6 +16754,8 @@ var init_generate_route_types = __esm({
|
|
|
16462
16754
|
__name(routeSegmentsToTsTypeLiteral, "routeSegmentsToTsTypeLiteral");
|
|
16463
16755
|
__name(routePatternToTsTypeLiterals, "routePatternToTsTypeLiterals");
|
|
16464
16756
|
__name(routePatternToRouteLiteral, "routePatternToRouteLiteral");
|
|
16757
|
+
__name(renderTypeUnion, "renderTypeUnion");
|
|
16758
|
+
__name(renderTypeAlias, "renderTypeAlias");
|
|
16465
16759
|
__name(createRoutePattern, "createRoutePattern");
|
|
16466
16760
|
DEFAULT_OUT_FILE = "farm-routes.d.ts";
|
|
16467
16761
|
__name(generateRouteTypes, "generateRouteTypes");
|
|
@@ -16471,17 +16765,17 @@ var init_generate_route_types = __esm({
|
|
|
16471
16765
|
|
|
16472
16766
|
// src/env-types.ts
|
|
16473
16767
|
async function generateEnvTypes(options) {
|
|
16474
|
-
const root =
|
|
16768
|
+
const root = path22.resolve(options.root);
|
|
16475
16769
|
const srcDir = options.srcDir || "src";
|
|
16476
16770
|
const outFile = options.outFile || DEFAULT_OUT_FILE2;
|
|
16477
|
-
const outPath =
|
|
16771
|
+
const outPath = path22.isAbsolute(outFile) ? outFile : path22.join(root, srcDir, outFile);
|
|
16478
16772
|
const content = createEnvTypeDeclarations(options, outPath);
|
|
16479
|
-
fs6.mkdirSync(
|
|
16773
|
+
fs6.mkdirSync(path22.dirname(outPath), { recursive: true });
|
|
16480
16774
|
writeFileIfChanged(outPath, content);
|
|
16481
16775
|
return outPath;
|
|
16482
16776
|
}
|
|
16483
16777
|
function createEnvTypeDeclarations(options, outPath) {
|
|
16484
|
-
const root =
|
|
16778
|
+
const root = path22.resolve(options.root);
|
|
16485
16779
|
const configPath = findConfigPath(root, options.configPath);
|
|
16486
16780
|
const configPaths = [
|
|
16487
16781
|
...(options.layerConfigPaths ?? []).filter((value) => fs6.existsSync(value)),
|
|
@@ -16544,11 +16838,11 @@ export {};
|
|
|
16544
16838
|
}
|
|
16545
16839
|
function findConfigPath(root, configPath) {
|
|
16546
16840
|
if (configPath) {
|
|
16547
|
-
const resolvedPath =
|
|
16841
|
+
const resolvedPath = path22.isAbsolute(configPath) ? configPath : path22.join(root, configPath);
|
|
16548
16842
|
return fs6.existsSync(resolvedPath) ? resolvedPath : null;
|
|
16549
16843
|
}
|
|
16550
16844
|
for (const filename of CONFIG_FILENAMES2) {
|
|
16551
|
-
const resolvedPath =
|
|
16845
|
+
const resolvedPath = path22.join(root, filename);
|
|
16552
16846
|
if (fs6.existsSync(resolvedPath)) {
|
|
16553
16847
|
return resolvedPath;
|
|
16554
16848
|
}
|
|
@@ -16609,15 +16903,15 @@ export {};
|
|
|
16609
16903
|
`;
|
|
16610
16904
|
}
|
|
16611
16905
|
function toTypeImportPath(outPath, targetPath) {
|
|
16612
|
-
const relativePath2 =
|
|
16906
|
+
const relativePath2 = path22.relative(path22.dirname(outPath), targetPath).replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
|
|
16613
16907
|
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
16614
16908
|
}
|
|
16615
|
-
var fs6,
|
|
16909
|
+
var fs6, path22, DEFAULT_OUT_FILE2, CONFIG_FILENAMES2;
|
|
16616
16910
|
var init_env_types = __esm({
|
|
16617
16911
|
"src/env-types.ts"() {
|
|
16618
16912
|
"use strict";
|
|
16619
16913
|
fs6 = __toESM(require("fs"));
|
|
16620
|
-
|
|
16914
|
+
path22 = __toESM(require("path"));
|
|
16621
16915
|
init_write_file_if_changed();
|
|
16622
16916
|
DEFAULT_OUT_FILE2 = "farm-env.d.ts";
|
|
16623
16917
|
CONFIG_FILENAMES2 = [
|
|
@@ -16650,8 +16944,8 @@ var init_env_types = __esm({
|
|
|
16650
16944
|
|
|
16651
16945
|
// src/image-types.ts
|
|
16652
16946
|
function generateFarmImageTypes(options) {
|
|
16653
|
-
const outputPath = options.outFile ?
|
|
16654
|
-
(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 });
|
|
16655
16949
|
writeFileIfChanged(outputPath, createFarmImageTypeDeclarations());
|
|
16656
16950
|
return outputPath;
|
|
16657
16951
|
}
|
|
@@ -16675,12 +16969,12 @@ declare module "*?url" {
|
|
|
16675
16969
|
}
|
|
16676
16970
|
`;
|
|
16677
16971
|
}
|
|
16678
|
-
var import_node_fs7,
|
|
16972
|
+
var import_node_fs7, import_node_path10, FARM_STATIC_IMAGE_EXTENSIONS;
|
|
16679
16973
|
var init_image_types = __esm({
|
|
16680
16974
|
"src/image-types.ts"() {
|
|
16681
16975
|
"use strict";
|
|
16682
16976
|
import_node_fs7 = require("fs");
|
|
16683
|
-
|
|
16977
|
+
import_node_path10 = __toESM(require("path"));
|
|
16684
16978
|
init_write_file_if_changed();
|
|
16685
16979
|
FARM_STATIC_IMAGE_EXTENSIONS = ["avif", "gif", "jpeg", "jpg", "png", "webp"];
|
|
16686
16980
|
__name(generateFarmImageTypes, "generateFarmImageTypes");
|
|
@@ -16692,9 +16986,9 @@ var init_image_types = __esm({
|
|
|
16692
16986
|
async function generateFarmI18nTypes(options) {
|
|
16693
16987
|
if (!options.config.enabled) return void 0;
|
|
16694
16988
|
const { signatures } = await readFarmI18nCatalogs(options.config);
|
|
16695
|
-
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");
|
|
16696
16990
|
const content = renderFarmI18nTypes(options.config.locales, signatures);
|
|
16697
|
-
(0, import_node_fs8.mkdirSync)((0,
|
|
16991
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path11.dirname)(outFile), { recursive: true });
|
|
16698
16992
|
writeFileIfChanged(outFile, content);
|
|
16699
16993
|
return outFile;
|
|
16700
16994
|
}
|
|
@@ -16735,12 +17029,12 @@ function argumentType(kind) {
|
|
|
16735
17029
|
return "string";
|
|
16736
17030
|
}
|
|
16737
17031
|
}
|
|
16738
|
-
var import_node_fs8,
|
|
17032
|
+
var import_node_fs8, import_node_path11;
|
|
16739
17033
|
var init_type_generator2 = __esm({
|
|
16740
17034
|
"src/i18n/type-generator.ts"() {
|
|
16741
17035
|
"use strict";
|
|
16742
17036
|
import_node_fs8 = require("fs");
|
|
16743
|
-
|
|
17037
|
+
import_node_path11 = require("path");
|
|
16744
17038
|
init_catalog();
|
|
16745
17039
|
init_write_file_if_changed();
|
|
16746
17040
|
__name(generateFarmI18nTypes, "generateFarmI18nTypes");
|
|
@@ -16762,7 +17056,8 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
16762
17056
|
const sourceRoots = getFarmSourceRoots({ root, srcDir, layers: options.layers });
|
|
16763
17057
|
const appDirs = getFarmAppDirectories({ root, srcDir, layers: options.layers });
|
|
16764
17058
|
const result = {
|
|
16765
|
-
apiRoutes: []
|
|
17059
|
+
apiRoutes: [],
|
|
17060
|
+
stalePaths: []
|
|
16766
17061
|
};
|
|
16767
17062
|
const unifiedTypesPath = (0, import_path11.join)(root, srcDir, "farm.d.ts");
|
|
16768
17063
|
const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
|
|
@@ -16778,22 +17073,29 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
16778
17073
|
unifiedSections.push(await createRouteTypeDeclarations(routeOptions, unifiedTypesPath));
|
|
16779
17074
|
result.routeTypesPath = unifiedTypesPath;
|
|
16780
17075
|
} else if (shouldGenerateRoutes) {
|
|
16781
|
-
|
|
17076
|
+
const routeOptions = {
|
|
16782
17077
|
root,
|
|
16783
17078
|
srcDir,
|
|
16784
17079
|
outFile: options.routeTypesOutFile,
|
|
16785
17080
|
extraRoutes: options.extraRoutes || [],
|
|
16786
17081
|
suppressLintOnLink: options.suppressLintOnLink,
|
|
16787
17082
|
sourceRoots
|
|
16788
|
-
}
|
|
17083
|
+
};
|
|
17084
|
+
if (options.check) {
|
|
17085
|
+
const routeTypesPath = resolveGeneratedPath(root, srcDir, options.routeTypesOutFile);
|
|
17086
|
+
const content = await createRouteTypeDeclarations(routeOptions, routeTypesPath);
|
|
17087
|
+
checkGeneratedFile(routeTypesPath, content, result.stalePaths);
|
|
17088
|
+
result.routeTypesPath = routeTypesPath;
|
|
17089
|
+
} else {
|
|
17090
|
+
result.routeTypesPath = await generateRouteTypes(routeOptions);
|
|
17091
|
+
}
|
|
16789
17092
|
}
|
|
16790
17093
|
if (shouldGenerateApi) {
|
|
16791
17094
|
const generator = new APITypeGenerator(appDirs);
|
|
16792
17095
|
const apiRoutes = generator.scanAPIRoutes();
|
|
16793
17096
|
const apiTypesPath = options.apiTypesOutFile ? (0, import_path11.resolve)(root, options.apiTypesOutFile) : (0, import_path11.join)(root, srcDir, "lib", "api.generated.ts");
|
|
16794
17097
|
const content = generator.generateAPIRouter(apiRoutes, { outFile: apiTypesPath });
|
|
16795
|
-
(
|
|
16796
|
-
writeFileIfChanged(apiTypesPath, content);
|
|
17098
|
+
writeOrCheckGeneratedFile(apiTypesPath, content, options.check, result.stalePaths);
|
|
16797
17099
|
result.apiTypesPath = apiTypesPath;
|
|
16798
17100
|
result.apiRoutes = apiRoutes;
|
|
16799
17101
|
}
|
|
@@ -16811,36 +17113,63 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
16811
17113
|
);
|
|
16812
17114
|
result.envTypesPath = unifiedTypesPath;
|
|
16813
17115
|
} else if (shouldGenerateEnv) {
|
|
16814
|
-
|
|
17116
|
+
const envOptions = {
|
|
16815
17117
|
root,
|
|
16816
17118
|
srcDir,
|
|
16817
17119
|
outFile: options.envTypesOutFile,
|
|
16818
17120
|
configPath: options.configPath,
|
|
16819
17121
|
layerConfigPaths: (options.layers ?? []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
|
|
16820
|
-
}
|
|
17122
|
+
};
|
|
17123
|
+
if (options.check) {
|
|
17124
|
+
const envTypesPath = resolveGeneratedPath(root, srcDir, options.envTypesOutFile);
|
|
17125
|
+
checkGeneratedFile(
|
|
17126
|
+
envTypesPath,
|
|
17127
|
+
createEnvTypeDeclarations(envOptions, envTypesPath),
|
|
17128
|
+
result.stalePaths
|
|
17129
|
+
);
|
|
17130
|
+
result.envTypesPath = envTypesPath;
|
|
17131
|
+
} else {
|
|
17132
|
+
result.envTypesPath = await generateEnvTypes(envOptions);
|
|
17133
|
+
}
|
|
16821
17134
|
}
|
|
16822
17135
|
if (shouldGenerateImages && options.imageTypesOutFile) {
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
}
|
|
17136
|
+
const imageTypesPath = resolveGeneratedPath(root, srcDir, options.imageTypesOutFile, false);
|
|
17137
|
+
if (options.check) {
|
|
17138
|
+
checkGeneratedFile(imageTypesPath, createFarmImageTypeDeclarations(), result.stalePaths);
|
|
17139
|
+
result.imageTypesPath = imageTypesPath;
|
|
17140
|
+
} else {
|
|
17141
|
+
result.imageTypesPath = generateFarmImageTypes({
|
|
17142
|
+
root,
|
|
17143
|
+
srcDir,
|
|
17144
|
+
outFile: options.imageTypesOutFile
|
|
17145
|
+
});
|
|
17146
|
+
}
|
|
16828
17147
|
}
|
|
16829
17148
|
if (shouldRefreshUnifiedTypes && options.i18nConfig?.enabled && !options.i18nTypesOutFile) {
|
|
16830
17149
|
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
16831
17150
|
unifiedSections.push(renderFarmI18nTypes(options.i18nConfig.locales, signatures));
|
|
16832
17151
|
result.i18nTypesPath = unifiedTypesPath;
|
|
16833
17152
|
} else if (shouldGenerateI18n && options.i18nConfig) {
|
|
16834
|
-
|
|
16835
|
-
root,
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
17153
|
+
if (options.check) {
|
|
17154
|
+
const i18nTypesPath = resolveGeneratedPath(root, srcDir, options.i18nTypesOutFile, false);
|
|
17155
|
+
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
17156
|
+
checkGeneratedFile(
|
|
17157
|
+
i18nTypesPath,
|
|
17158
|
+
renderFarmI18nTypes(options.i18nConfig.locales, signatures),
|
|
17159
|
+
result.stalePaths
|
|
17160
|
+
);
|
|
17161
|
+
result.i18nTypesPath = i18nTypesPath;
|
|
17162
|
+
} else {
|
|
17163
|
+
result.i18nTypesPath = await generateFarmI18nTypes({
|
|
17164
|
+
root,
|
|
17165
|
+
srcDir,
|
|
17166
|
+
config: options.i18nConfig,
|
|
17167
|
+
outFile: options.i18nTypesOutFile
|
|
17168
|
+
});
|
|
17169
|
+
}
|
|
16840
17170
|
}
|
|
16841
17171
|
if (shouldRefreshUnifiedTypes) {
|
|
16842
|
-
(
|
|
16843
|
-
writeFileIfChanged(
|
|
17172
|
+
writeOrCheckGeneratedFile(
|
|
16844
17173
|
unifiedTypesPath,
|
|
16845
17174
|
`/**
|
|
16846
17175
|
* Generated by Farm.js. Do not edit.
|
|
@@ -16849,13 +17178,37 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
16849
17178
|
|
|
16850
17179
|
import "@farm.js/core/image";
|
|
16851
17180
|
|
|
16852
|
-
${unifiedSections.join("\n")}
|
|
17181
|
+
${unifiedSections.map((section) => section.trimEnd()).join("\n\n")}
|
|
17182
|
+
`,
|
|
17183
|
+
options.check,
|
|
17184
|
+
result.stalePaths
|
|
16853
17185
|
);
|
|
16854
17186
|
result.typesPath = unifiedTypesPath;
|
|
16855
|
-
|
|
17187
|
+
if (options.check) {
|
|
17188
|
+
collectLegacyTypeArtifacts(root, srcDir, result.stalePaths);
|
|
17189
|
+
} else {
|
|
17190
|
+
removeLegacyTypeArtifacts(root, srcDir);
|
|
17191
|
+
}
|
|
16856
17192
|
}
|
|
16857
17193
|
return result;
|
|
16858
17194
|
}
|
|
17195
|
+
function resolveGeneratedPath(root, srcDir, outFile, relativeToSrc = true) {
|
|
17196
|
+
if ((0, import_path11.isAbsolute)(outFile)) return (0, import_path11.resolve)(outFile);
|
|
17197
|
+
return (0, import_path11.resolve)(root, relativeToSrc ? (0, import_path11.join)(srcDir, outFile) : outFile);
|
|
17198
|
+
}
|
|
17199
|
+
function writeOrCheckGeneratedFile(filePath, content, check, stalePaths) {
|
|
17200
|
+
if (check) {
|
|
17201
|
+
checkGeneratedFile(filePath, content, stalePaths);
|
|
17202
|
+
return;
|
|
17203
|
+
}
|
|
17204
|
+
(0, import_fs4.mkdirSync)((0, import_path11.dirname)(filePath), { recursive: true });
|
|
17205
|
+
writeFileIfChanged(filePath, content);
|
|
17206
|
+
}
|
|
17207
|
+
function checkGeneratedFile(filePath, content, stalePaths) {
|
|
17208
|
+
if (!(0, import_fs4.existsSync)(filePath) || (0, import_fs4.readFileSync)(filePath, "utf8") !== content) {
|
|
17209
|
+
stalePaths.push(filePath);
|
|
17210
|
+
}
|
|
17211
|
+
}
|
|
16859
17212
|
function removeLegacyTypeArtifacts(root, srcDir) {
|
|
16860
17213
|
for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
|
|
16861
17214
|
const filePath = (0, import_path11.join)(root, srcDir, fileName);
|
|
@@ -16866,6 +17219,13 @@ function removeLegacyTypeArtifacts(root, srcDir) {
|
|
|
16866
17219
|
}
|
|
16867
17220
|
}
|
|
16868
17221
|
}
|
|
17222
|
+
function collectLegacyTypeArtifacts(root, srcDir, stalePaths) {
|
|
17223
|
+
for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
|
|
17224
|
+
const filePath = (0, import_path11.join)(root, srcDir, fileName);
|
|
17225
|
+
if (!(0, import_fs4.existsSync)(filePath)) continue;
|
|
17226
|
+
if ((0, import_fs4.readFileSync)(filePath, "utf8").includes(marker)) stalePaths.push(filePath);
|
|
17227
|
+
}
|
|
17228
|
+
}
|
|
16869
17229
|
var import_fs4, import_path11, LEGACY_TYPE_ARTIFACTS;
|
|
16870
17230
|
var init_type_artifacts = __esm({
|
|
16871
17231
|
"src/type-artifacts.ts"() {
|
|
@@ -16881,6 +17241,9 @@ var init_type_artifacts = __esm({
|
|
|
16881
17241
|
init_layers();
|
|
16882
17242
|
init_write_file_if_changed();
|
|
16883
17243
|
__name(generateFarmTypeArtifacts, "generateFarmTypeArtifacts");
|
|
17244
|
+
__name(resolveGeneratedPath, "resolveGeneratedPath");
|
|
17245
|
+
__name(writeOrCheckGeneratedFile, "writeOrCheckGeneratedFile");
|
|
17246
|
+
__name(checkGeneratedFile, "checkGeneratedFile");
|
|
16884
17247
|
LEGACY_TYPE_ARTIFACTS = [
|
|
16885
17248
|
["farm-routes.d.ts", "Auto-generated route types"],
|
|
16886
17249
|
["farm-env.d.ts", "Auto-generated env types"],
|
|
@@ -16888,6 +17251,7 @@ var init_type_artifacts = __esm({
|
|
|
16888
17251
|
["farm-i18n.d.ts", "Generated by Farm.js"]
|
|
16889
17252
|
];
|
|
16890
17253
|
__name(removeLegacyTypeArtifacts, "removeLegacyTypeArtifacts");
|
|
17254
|
+
__name(collectLegacyTypeArtifacts, "collectLegacyTypeArtifacts");
|
|
16891
17255
|
}
|
|
16892
17256
|
});
|
|
16893
17257
|
|
|
@@ -16895,7 +17259,7 @@ var init_type_artifacts = __esm({
|
|
|
16895
17259
|
var version;
|
|
16896
17260
|
var init_package = __esm({
|
|
16897
17261
|
"package.json"() {
|
|
16898
|
-
version = "0.1.0-beta.
|
|
17262
|
+
version = "0.1.0-beta.17";
|
|
16899
17263
|
}
|
|
16900
17264
|
});
|
|
16901
17265
|
|
|
@@ -17075,12 +17439,12 @@ async function createBlurDataURL(bytes) {
|
|
|
17075
17439
|
return void 0;
|
|
17076
17440
|
}
|
|
17077
17441
|
}
|
|
17078
|
-
var import_promises7,
|
|
17442
|
+
var import_promises7, import_node_path12, import_image_size2, FARM_IMAGE_ID_PREFIX, STATIC_IMAGE_RE, SCRIPT_IMPORTER_RE;
|
|
17079
17443
|
var init_image_vite = __esm({
|
|
17080
17444
|
"src/image-vite.ts"() {
|
|
17081
17445
|
"use strict";
|
|
17082
17446
|
import_promises7 = require("fs/promises");
|
|
17083
|
-
|
|
17447
|
+
import_node_path12 = __toESM(require("path"));
|
|
17084
17448
|
import_image_size2 = require("image-size");
|
|
17085
17449
|
FARM_IMAGE_ID_PREFIX = "\0farm:image:";
|
|
17086
17450
|
STATIC_IMAGE_RE = /\.(?:avif|gif|jpe?g|png|webp)$/i;
|
|
@@ -17523,106 +17887,6 @@ var init_image_server = __esm({
|
|
|
17523
17887
|
}
|
|
17524
17888
|
});
|
|
17525
17889
|
|
|
17526
|
-
// src/server/vite-config.ts
|
|
17527
|
-
function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
|
|
17528
|
-
const resolvedProjectRoot = import_node_path12.default.resolve(projectRoot);
|
|
17529
|
-
return appDirectories.map((appDirectory) => {
|
|
17530
|
-
const relativeAppDirectory = import_node_path12.default.relative(resolvedProjectRoot, import_node_path12.default.resolve(appDirectory)).replace(/\\/g, "/");
|
|
17531
|
-
const prefix = relativeAppDirectory || ".";
|
|
17532
|
-
return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
|
|
17533
|
-
});
|
|
17534
|
-
}
|
|
17535
|
-
function createFarmClientOptimizeDepsConfig(entries) {
|
|
17536
|
-
return {
|
|
17537
|
-
// Keep normal application dependency discovery for CJS-only packages, but
|
|
17538
|
-
// seed every Farm browser runtime so React is present in the first crawl.
|
|
17539
|
-
noDiscovery: false,
|
|
17540
|
-
// Waiting for the crawl avoids serving a partial optimizer generation and
|
|
17541
|
-
// then changing browser hashes while hydration is already in progress.
|
|
17542
|
-
holdUntilCrawlEnd: true,
|
|
17543
|
-
include: [...FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE],
|
|
17544
|
-
// Farm's HTML boots through a virtual module and imports route UI lazily.
|
|
17545
|
-
// Explicit entries let Vite finish that crawl before a navigation can
|
|
17546
|
-
// rotate the optimizer hash underneath a hydrated React runtime.
|
|
17547
|
-
...entries?.length ? { entries: [...entries] } : {}
|
|
17548
|
-
};
|
|
17549
|
-
}
|
|
17550
|
-
function mergeNoExternal(farmValue, userValue) {
|
|
17551
|
-
if (farmValue === true || userValue === true) return true;
|
|
17552
|
-
const normalize = /* @__PURE__ */ __name((value) => value == null || value === true ? [] : Array.isArray(value) ? value : [value], "normalize");
|
|
17553
|
-
return Array.from(/* @__PURE__ */ new Set([...normalize(farmValue), ...normalize(userValue)]));
|
|
17554
|
-
}
|
|
17555
|
-
function mergeFarmViteConfig(farmConfig, userConfig = {}) {
|
|
17556
|
-
const noDiscovery = userConfig.optimizeDeps?.noDiscovery ?? farmConfig.optimizeDeps?.noDiscovery;
|
|
17557
|
-
const holdUntilCrawlEnd = userConfig.optimizeDeps?.holdUntilCrawlEnd ?? (userConfig.optimizeDeps?.noDiscovery === true ? false : farmConfig.optimizeDeps?.holdUntilCrawlEnd);
|
|
17558
|
-
return {
|
|
17559
|
-
...farmConfig,
|
|
17560
|
-
...userConfig,
|
|
17561
|
-
plugins: [...farmConfig.plugins || [], ...userConfig.plugins || []],
|
|
17562
|
-
server: {
|
|
17563
|
-
...farmConfig.server,
|
|
17564
|
-
...userConfig.server
|
|
17565
|
-
},
|
|
17566
|
-
resolve: {
|
|
17567
|
-
...farmConfig.resolve,
|
|
17568
|
-
...userConfig.resolve,
|
|
17569
|
-
dedupe: Array.from(
|
|
17570
|
-
/* @__PURE__ */ new Set([...farmConfig.resolve?.dedupe || [], ...userConfig.resolve?.dedupe || []])
|
|
17571
|
-
)
|
|
17572
|
-
},
|
|
17573
|
-
optimizeDeps: {
|
|
17574
|
-
...farmConfig.optimizeDeps,
|
|
17575
|
-
...userConfig.optimizeDeps,
|
|
17576
|
-
noDiscovery,
|
|
17577
|
-
holdUntilCrawlEnd,
|
|
17578
|
-
include: Array.from(
|
|
17579
|
-
/* @__PURE__ */ new Set([
|
|
17580
|
-
...farmConfig.optimizeDeps?.include || [],
|
|
17581
|
-
...userConfig.optimizeDeps?.include || []
|
|
17582
|
-
])
|
|
17583
|
-
),
|
|
17584
|
-
exclude: Array.from(
|
|
17585
|
-
/* @__PURE__ */ new Set([
|
|
17586
|
-
...farmConfig.optimizeDeps?.exclude || [],
|
|
17587
|
-
...userConfig.optimizeDeps?.exclude || []
|
|
17588
|
-
])
|
|
17589
|
-
)
|
|
17590
|
-
},
|
|
17591
|
-
ssr: {
|
|
17592
|
-
...farmConfig.ssr,
|
|
17593
|
-
...userConfig.ssr,
|
|
17594
|
-
noExternal: mergeNoExternal(farmConfig.ssr?.noExternal, userConfig.ssr?.noExternal)
|
|
17595
|
-
}
|
|
17596
|
-
};
|
|
17597
|
-
}
|
|
17598
|
-
var import_node_path12, FARM_CLIENT_ENTRY_PATTERN, FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE;
|
|
17599
|
-
var init_vite_config = __esm({
|
|
17600
|
-
"src/server/vite-config.ts"() {
|
|
17601
|
-
"use strict";
|
|
17602
|
-
import_node_path12 = __toESM(require("path"));
|
|
17603
|
-
FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
|
|
17604
|
-
FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
|
|
17605
|
-
"react",
|
|
17606
|
-
"react-dom",
|
|
17607
|
-
"react-dom/client",
|
|
17608
|
-
"react/jsx-runtime",
|
|
17609
|
-
"react/jsx-dev-runtime",
|
|
17610
|
-
"@farm.js/core/client",
|
|
17611
|
-
"@farm.js/core/plugin/client",
|
|
17612
|
-
"@farm.js/core/deferred",
|
|
17613
|
-
"@farm.js/core/deployment",
|
|
17614
|
-
"@farm.js/core/i18n/client",
|
|
17615
|
-
"@farm.js/core/query/client",
|
|
17616
|
-
"@farm.js/core/server-fn/client",
|
|
17617
|
-
"@farm.js/core/server-query/client"
|
|
17618
|
-
];
|
|
17619
|
-
__name(createFarmClientOptimizeDepsEntries, "createFarmClientOptimizeDepsEntries");
|
|
17620
|
-
__name(createFarmClientOptimizeDepsConfig, "createFarmClientOptimizeDepsConfig");
|
|
17621
|
-
__name(mergeNoExternal, "mergeNoExternal");
|
|
17622
|
-
__name(mergeFarmViteConfig, "mergeFarmViteConfig");
|
|
17623
|
-
}
|
|
17624
|
-
});
|
|
17625
|
-
|
|
17626
17890
|
// src/docs/pixel-border-css.ts
|
|
17627
17891
|
var farmDocsPixelBorderCss;
|
|
17628
17892
|
var init_pixel_border_css = __esm({
|
|
@@ -27739,7 +28003,7 @@ async function defineConfig2(config = {}) {
|
|
|
27739
28003
|
// Stub out problematic server-only modules during dev mode
|
|
27740
28004
|
alias: {
|
|
27741
28005
|
...getFarmLayerAliases(config.layers),
|
|
27742
|
-
|
|
28006
|
+
...createFarmSourceAlias(appRoot, config.srcDir),
|
|
27743
28007
|
// Nitro internals that should not be resolved in browser
|
|
27744
28008
|
"supports-color": "data:text/javascript,export default false; export const supportsColor = false; export const stdout = false; export const stderr = false;",
|
|
27745
28009
|
"@poppinss/dumper": "data:text/javascript,export default {};",
|
|
@@ -29190,6 +29454,7 @@ init_fonts();
|
|
|
29190
29454
|
|
|
29191
29455
|
// src/route-runtime-manifest.ts
|
|
29192
29456
|
var import_path8 = __toESM(require("path"));
|
|
29457
|
+
init_deployment();
|
|
29193
29458
|
init_route_runtime();
|
|
29194
29459
|
init_ssg();
|
|
29195
29460
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
@@ -29250,10 +29515,15 @@ async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
|
29250
29515
|
}
|
|
29251
29516
|
__name(writeFarmRouteRuntimeManifest, "writeFarmRouteRuntimeManifest");
|
|
29252
29517
|
function validateFarmRouteRuntimeDeployment(manifest, preset) {
|
|
29253
|
-
const runtime =
|
|
29518
|
+
const runtime = getFarmPresetRuntime(preset);
|
|
29254
29519
|
const warnings = /* @__PURE__ */ new Set();
|
|
29255
29520
|
for (const route of manifest.routes) {
|
|
29256
29521
|
if (route.rendering === "static") continue;
|
|
29522
|
+
if (runtime === "unknown" && route.runtime !== "auto") {
|
|
29523
|
+
warnings.add(
|
|
29524
|
+
`Preset "${preset}" has an unknown runtime, so Farm could not verify routes that explicitly require node or edge.`
|
|
29525
|
+
);
|
|
29526
|
+
}
|
|
29257
29527
|
if (runtime !== "unknown" && route.runtime !== "auto" && route.runtime !== runtime) {
|
|
29258
29528
|
throw new Error(
|
|
29259
29529
|
`Route "${route.pattern}" requires the ${route.runtime} runtime, but preset "${preset}" emits ${runtime} functions. Choose a compatible preset or change the route runtime.`
|
|
@@ -29273,16 +29543,6 @@ function validateFarmRouteRuntimeDeployment(manifest, preset) {
|
|
|
29273
29543
|
return { runtime, warnings: Array.from(warnings) };
|
|
29274
29544
|
}
|
|
29275
29545
|
__name(validateFarmRouteRuntimeDeployment, "validateFarmRouteRuntimeDeployment");
|
|
29276
|
-
function getPresetRuntime(preset) {
|
|
29277
|
-
if (preset === "cloudflare" || preset === "cloudflare-pages" || preset === "cloudflare-module" || preset === "netlify-edge" || preset === "vercel-edge" || preset === "deno") {
|
|
29278
|
-
return "edge";
|
|
29279
|
-
}
|
|
29280
|
-
if (preset === "node-server" || preset === "vercel" || preset === "netlify" || preset === "aws-lambda" || preset === "azure" || preset === "firebase" || preset === "bun") {
|
|
29281
|
-
return "node";
|
|
29282
|
-
}
|
|
29283
|
-
return "unknown";
|
|
29284
|
-
}
|
|
29285
|
-
__name(getPresetRuntime, "getPresetRuntime");
|
|
29286
29546
|
function normalizeManifestSource(root, modulePath) {
|
|
29287
29547
|
const queryIndex = modulePath.indexOf("?");
|
|
29288
29548
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
@@ -29552,6 +29812,7 @@ __name(withVite5TransformContext, "withVite5TransformContext");
|
|
|
29552
29812
|
|
|
29553
29813
|
// src/nitro/universal-build.ts
|
|
29554
29814
|
init_font_vite();
|
|
29815
|
+
init_vite_config();
|
|
29555
29816
|
var import_meta = {};
|
|
29556
29817
|
function preloadFarmNitroRuntime() {
|
|
29557
29818
|
return import("nitro").then(
|
|
@@ -31945,9 +32206,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
31945
32206
|
postcss: postcssConfigDir
|
|
31946
32207
|
} : void 0,
|
|
31947
32208
|
resolve: {
|
|
31948
|
-
alias:
|
|
31949
|
-
"@": import_path12.default.resolve(root, "src")
|
|
31950
|
-
},
|
|
32209
|
+
alias: createFarmSourceAlias(root, config.srcDir),
|
|
31951
32210
|
// Programmatic route wrappers are created inside @farm.js/core. Resolve
|
|
31952
32211
|
// their React imports from the application so React 18/19 elements and
|
|
31953
32212
|
// the selected server renderer always share the same runtime instance.
|
|
@@ -35605,6 +35864,9 @@ async function createProjectModuleServer(createViteServer, config, root) {
|
|
|
35605
35864
|
middlewareMode: true,
|
|
35606
35865
|
hmr: false
|
|
35607
35866
|
},
|
|
35867
|
+
resolve: {
|
|
35868
|
+
alias: createFarmSourceAlias(root, config.srcDir)
|
|
35869
|
+
},
|
|
35608
35870
|
optimizeDeps: {
|
|
35609
35871
|
noDiscovery: true
|
|
35610
35872
|
},
|