@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
package/dist/vite.cjs
CHANGED
|
@@ -1845,6 +1845,13 @@ var init_cache_invalidation = __esm({
|
|
|
1845
1845
|
}
|
|
1846
1846
|
});
|
|
1847
1847
|
|
|
1848
|
+
// src/server-fn-error.ts
|
|
1849
|
+
var init_server_fn_error = __esm({
|
|
1850
|
+
"src/server-fn-error.ts"() {
|
|
1851
|
+
"use strict";
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1848
1855
|
// src/server-action-security.ts
|
|
1849
1856
|
function resolveServerActionsConfig(config) {
|
|
1850
1857
|
const allowedOrigins = (config?.allowedOrigins ?? []).map(normalizeAllowedOriginPattern);
|
|
@@ -1938,6 +1945,7 @@ var init_server_action_security = __esm({
|
|
|
1938
1945
|
"use strict";
|
|
1939
1946
|
import_node_async_hooks = require("async_hooks");
|
|
1940
1947
|
init_cache_invalidation();
|
|
1948
|
+
init_server_fn_error();
|
|
1941
1949
|
DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1e6;
|
|
1942
1950
|
SERVER_ACTION_STORAGE_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionStorage");
|
|
1943
1951
|
__name(resolveServerActionsConfig, "resolveServerActionsConfig");
|
|
@@ -4246,6 +4254,135 @@ var init_preload = __esm({
|
|
|
4246
4254
|
}
|
|
4247
4255
|
});
|
|
4248
4256
|
|
|
4257
|
+
// src/security.ts
|
|
4258
|
+
function resolveFarmSecurityConfig(input) {
|
|
4259
|
+
if (input === void 0) return { csp: false };
|
|
4260
|
+
if (!isPlainRecord(input)) {
|
|
4261
|
+
throw new TypeError("security must be an object containing the csp option.");
|
|
4262
|
+
}
|
|
4263
|
+
if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
|
|
4264
|
+
throw new TypeError(
|
|
4265
|
+
"security.contentSecurityPolicy is not supported. Use security.csp instead."
|
|
4266
|
+
);
|
|
4267
|
+
}
|
|
4268
|
+
const csp = input.csp;
|
|
4269
|
+
if (csp === void 0 || csp === false) return { csp: false };
|
|
4270
|
+
if (typeof csp === "string") {
|
|
4271
|
+
return {
|
|
4272
|
+
csp: {
|
|
4273
|
+
value: validateSerializedCsp(csp),
|
|
4274
|
+
reportOnly: false
|
|
4275
|
+
}
|
|
4276
|
+
};
|
|
4277
|
+
}
|
|
4278
|
+
if (!isPlainRecord(csp)) {
|
|
4279
|
+
throw new TypeError("security.csp must be a policy string, false, or an options object.");
|
|
4280
|
+
}
|
|
4281
|
+
const reportOnly = validateReportOnly(csp.reportOnly);
|
|
4282
|
+
if (Object.prototype.hasOwnProperty.call(csp, "value")) {
|
|
4283
|
+
if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
|
|
4284
|
+
throw new TypeError(
|
|
4285
|
+
"Resolved security.csp values cannot include policy or directives options."
|
|
4286
|
+
);
|
|
4287
|
+
}
|
|
4288
|
+
return {
|
|
4289
|
+
csp: {
|
|
4290
|
+
value: validateSerializedCsp(csp.value),
|
|
4291
|
+
reportOnly
|
|
4292
|
+
}
|
|
4293
|
+
};
|
|
4294
|
+
}
|
|
4295
|
+
const { policy, directives } = csp;
|
|
4296
|
+
if (policy !== void 0 && directives !== void 0) {
|
|
4297
|
+
throw new TypeError("security.csp accepts either policy or directives, not both.");
|
|
4298
|
+
}
|
|
4299
|
+
if (policy === void 0 && directives === void 0) {
|
|
4300
|
+
throw new TypeError("security.csp requires a policy string or directives object.");
|
|
4301
|
+
}
|
|
4302
|
+
return {
|
|
4303
|
+
csp: {
|
|
4304
|
+
value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
|
|
4305
|
+
reportOnly
|
|
4306
|
+
}
|
|
4307
|
+
};
|
|
4308
|
+
}
|
|
4309
|
+
function serializeFarmCspDirectives(directives) {
|
|
4310
|
+
if (!isPlainRecord(directives)) {
|
|
4311
|
+
throw new TypeError("security.csp.directives must be an object.");
|
|
4312
|
+
}
|
|
4313
|
+
const serialized = [];
|
|
4314
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
4315
|
+
for (const [configuredName, configuredValue] of Object.entries(directives)) {
|
|
4316
|
+
if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
|
|
4317
|
+
continue;
|
|
4318
|
+
}
|
|
4319
|
+
const name = normalizeDirectiveName(configuredName);
|
|
4320
|
+
if (normalizedNames.has(name)) {
|
|
4321
|
+
throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
|
|
4322
|
+
}
|
|
4323
|
+
normalizedNames.add(name);
|
|
4324
|
+
const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
|
|
4325
|
+
validateDirectiveValue
|
|
4326
|
+
);
|
|
4327
|
+
serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
|
|
4328
|
+
}
|
|
4329
|
+
if (serialized.length === 0) {
|
|
4330
|
+
throw new TypeError("security.csp.directives must contain at least one enabled directive.");
|
|
4331
|
+
}
|
|
4332
|
+
return serialized.join("; ");
|
|
4333
|
+
}
|
|
4334
|
+
function normalizeDirectiveName(value) {
|
|
4335
|
+
const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4336
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
4337
|
+
throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
|
|
4338
|
+
}
|
|
4339
|
+
return name;
|
|
4340
|
+
}
|
|
4341
|
+
function validateDirectiveValue(value) {
|
|
4342
|
+
if (typeof value !== "string") {
|
|
4343
|
+
throw new TypeError("security.csp directive values must be strings or booleans.");
|
|
4344
|
+
}
|
|
4345
|
+
const normalized = value.trim();
|
|
4346
|
+
if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4347
|
+
throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
|
|
4348
|
+
}
|
|
4349
|
+
return normalized;
|
|
4350
|
+
}
|
|
4351
|
+
function validateSerializedCsp(value) {
|
|
4352
|
+
if (typeof value !== "string") {
|
|
4353
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4354
|
+
}
|
|
4355
|
+
const normalized = value.trim().replace(/;+$/g, "").trim();
|
|
4356
|
+
if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4357
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4358
|
+
}
|
|
4359
|
+
return normalized;
|
|
4360
|
+
}
|
|
4361
|
+
function validateReportOnly(value) {
|
|
4362
|
+
if (value === void 0) return false;
|
|
4363
|
+
if (typeof value !== "boolean") {
|
|
4364
|
+
throw new TypeError("security.csp.reportOnly must be a boolean.");
|
|
4365
|
+
}
|
|
4366
|
+
return value;
|
|
4367
|
+
}
|
|
4368
|
+
function isPlainRecord(value) {
|
|
4369
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4370
|
+
const prototype = Object.getPrototypeOf(value);
|
|
4371
|
+
return prototype === Object.prototype || prototype === null;
|
|
4372
|
+
}
|
|
4373
|
+
var init_security = __esm({
|
|
4374
|
+
"src/security.ts"() {
|
|
4375
|
+
"use strict";
|
|
4376
|
+
__name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
|
|
4377
|
+
__name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
|
|
4378
|
+
__name(normalizeDirectiveName, "normalizeDirectiveName");
|
|
4379
|
+
__name(validateDirectiveValue, "validateDirectiveValue");
|
|
4380
|
+
__name(validateSerializedCsp, "validateSerializedCsp");
|
|
4381
|
+
__name(validateReportOnly, "validateReportOnly");
|
|
4382
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
4383
|
+
}
|
|
4384
|
+
});
|
|
4385
|
+
|
|
4249
4386
|
// src/write-file-if-changed.ts
|
|
4250
4387
|
function writeFileIfChanged(filePath, content) {
|
|
4251
4388
|
try {
|
|
@@ -8914,6 +9051,7 @@ var init_config2 = __esm({
|
|
|
8914
9051
|
init_config();
|
|
8915
9052
|
init_auth_config();
|
|
8916
9053
|
init_preload();
|
|
9054
|
+
init_security();
|
|
8917
9055
|
init_config_entry();
|
|
8918
9056
|
__name(getDeployTargetForPreset, "getDeployTargetForPreset");
|
|
8919
9057
|
DOCS_CONFIG_FILENAMES = [
|
|
@@ -19510,6 +19648,7 @@ init_devtools_config();
|
|
|
19510
19648
|
init_config();
|
|
19511
19649
|
init_auth_config();
|
|
19512
19650
|
init_preload();
|
|
19651
|
+
init_security();
|
|
19513
19652
|
var defaultDocsConfig = {
|
|
19514
19653
|
enabled: false,
|
|
19515
19654
|
entry: "/docs",
|
|
@@ -19577,6 +19716,7 @@ var _FarmApp = class _FarmApp {
|
|
|
19577
19716
|
routeRules: normalizeRouteRules(config.routeRules),
|
|
19578
19717
|
context: config.context || (() => void 0),
|
|
19579
19718
|
serverActions: resolveServerActionsConfig(config.serverActions),
|
|
19719
|
+
security: resolveFarmSecurityConfig(config.security),
|
|
19580
19720
|
images: resolveFarmImageConfig(config.images),
|
|
19581
19721
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
19582
19722
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|
|
@@ -21321,6 +21461,15 @@ function routePatternToRouteLiteral(pattern) {
|
|
|
21321
21461
|
return JSON.stringify(pattern);
|
|
21322
21462
|
}
|
|
21323
21463
|
__name(routePatternToRouteLiteral, "routePatternToRouteLiteral");
|
|
21464
|
+
function renderTypeUnion(values) {
|
|
21465
|
+
return values.length <= 1 ? values[0] || "never" : `
|
|
21466
|
+
| ${values.join("\n | ")}`;
|
|
21467
|
+
}
|
|
21468
|
+
__name(renderTypeUnion, "renderTypeUnion");
|
|
21469
|
+
function renderTypeAlias(name, value) {
|
|
21470
|
+
return `export type ${name} =${value.startsWith("\n") ? "" : " "}${value};`;
|
|
21471
|
+
}
|
|
21472
|
+
__name(renderTypeAlias, "renderTypeAlias");
|
|
21324
21473
|
function createRoutePattern(route) {
|
|
21325
21474
|
if (route.segments.length === 0) return "/";
|
|
21326
21475
|
return "/" + route.segments.map((seg) => {
|
|
@@ -21383,9 +21532,9 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
21383
21532
|
const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
|
|
21384
21533
|
const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
|
|
21385
21534
|
const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
|
|
21386
|
-
const routePathType = suppressLintOnLink ? "string" : typeLiterals
|
|
21387
|
-
const routePatternType = suppressLintOnLink ? "string" : patternLiterals
|
|
21388
|
-
const routeModulePatternType = routeModulePatternLiterals
|
|
21535
|
+
const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
|
|
21536
|
+
const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
|
|
21537
|
+
const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
|
|
21389
21538
|
const routeTypesImportPath = `./${path14.basename(outPath).replace(/\.d\.ts$/, "")}`;
|
|
21390
21539
|
const linkAugmentationBlock = suppressLintOnLink ? "" : `
|
|
21391
21540
|
declare module "@farm.js/core/client" {
|
|
@@ -21427,9 +21576,9 @@ declare global {
|
|
|
21427
21576
|
* Regenerated on dev start and when routes change.
|
|
21428
21577
|
* Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
|
|
21429
21578
|
*/
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21579
|
+
${renderTypeAlias("RoutePath", routePathType)}
|
|
21580
|
+
${renderTypeAlias("RoutePattern", routePatternType)}
|
|
21581
|
+
${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentationBlock}${routeModuleAugmentationBlock}
|
|
21433
21582
|
`;
|
|
21434
21583
|
return content;
|
|
21435
21584
|
}
|
|
@@ -21711,7 +21860,8 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21711
21860
|
const sourceRoots = getFarmSourceRoots({ root, srcDir, layers: options.layers });
|
|
21712
21861
|
const appDirs = getFarmAppDirectories({ root, srcDir, layers: options.layers });
|
|
21713
21862
|
const result = {
|
|
21714
|
-
apiRoutes: []
|
|
21863
|
+
apiRoutes: [],
|
|
21864
|
+
stalePaths: []
|
|
21715
21865
|
};
|
|
21716
21866
|
const unifiedTypesPath = (0, import_path8.join)(root, srcDir, "farm.d.ts");
|
|
21717
21867
|
const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
|
|
@@ -21727,22 +21877,29 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21727
21877
|
unifiedSections.push(await createRouteTypeDeclarations(routeOptions, unifiedTypesPath));
|
|
21728
21878
|
result.routeTypesPath = unifiedTypesPath;
|
|
21729
21879
|
} else if (shouldGenerateRoutes) {
|
|
21730
|
-
|
|
21880
|
+
const routeOptions = {
|
|
21731
21881
|
root,
|
|
21732
21882
|
srcDir,
|
|
21733
21883
|
outFile: options.routeTypesOutFile,
|
|
21734
21884
|
extraRoutes: options.extraRoutes || [],
|
|
21735
21885
|
suppressLintOnLink: options.suppressLintOnLink,
|
|
21736
21886
|
sourceRoots
|
|
21737
|
-
}
|
|
21887
|
+
};
|
|
21888
|
+
if (options.check) {
|
|
21889
|
+
const routeTypesPath = resolveGeneratedPath(root, srcDir, options.routeTypesOutFile);
|
|
21890
|
+
const content = await createRouteTypeDeclarations(routeOptions, routeTypesPath);
|
|
21891
|
+
checkGeneratedFile(routeTypesPath, content, result.stalePaths);
|
|
21892
|
+
result.routeTypesPath = routeTypesPath;
|
|
21893
|
+
} else {
|
|
21894
|
+
result.routeTypesPath = await generateRouteTypes(routeOptions);
|
|
21895
|
+
}
|
|
21738
21896
|
}
|
|
21739
21897
|
if (shouldGenerateApi) {
|
|
21740
21898
|
const generator = new APITypeGenerator(appDirs);
|
|
21741
21899
|
const apiRoutes = generator.scanAPIRoutes();
|
|
21742
21900
|
const apiTypesPath = options.apiTypesOutFile ? (0, import_path8.resolve)(root, options.apiTypesOutFile) : (0, import_path8.join)(root, srcDir, "lib", "api.generated.ts");
|
|
21743
21901
|
const content = generator.generateAPIRouter(apiRoutes, { outFile: apiTypesPath });
|
|
21744
|
-
(
|
|
21745
|
-
writeFileIfChanged(apiTypesPath, content);
|
|
21902
|
+
writeOrCheckGeneratedFile(apiTypesPath, content, options.check, result.stalePaths);
|
|
21746
21903
|
result.apiTypesPath = apiTypesPath;
|
|
21747
21904
|
result.apiRoutes = apiRoutes;
|
|
21748
21905
|
}
|
|
@@ -21760,36 +21917,63 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21760
21917
|
);
|
|
21761
21918
|
result.envTypesPath = unifiedTypesPath;
|
|
21762
21919
|
} else if (shouldGenerateEnv) {
|
|
21763
|
-
|
|
21920
|
+
const envOptions = {
|
|
21764
21921
|
root,
|
|
21765
21922
|
srcDir,
|
|
21766
21923
|
outFile: options.envTypesOutFile,
|
|
21767
21924
|
configPath: options.configPath,
|
|
21768
21925
|
layerConfigPaths: (options.layers ?? []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
|
|
21769
|
-
}
|
|
21926
|
+
};
|
|
21927
|
+
if (options.check) {
|
|
21928
|
+
const envTypesPath = resolveGeneratedPath(root, srcDir, options.envTypesOutFile);
|
|
21929
|
+
checkGeneratedFile(
|
|
21930
|
+
envTypesPath,
|
|
21931
|
+
createEnvTypeDeclarations(envOptions, envTypesPath),
|
|
21932
|
+
result.stalePaths
|
|
21933
|
+
);
|
|
21934
|
+
result.envTypesPath = envTypesPath;
|
|
21935
|
+
} else {
|
|
21936
|
+
result.envTypesPath = await generateEnvTypes(envOptions);
|
|
21937
|
+
}
|
|
21770
21938
|
}
|
|
21771
21939
|
if (shouldGenerateImages && options.imageTypesOutFile) {
|
|
21772
|
-
|
|
21773
|
-
|
|
21774
|
-
|
|
21775
|
-
|
|
21776
|
-
}
|
|
21940
|
+
const imageTypesPath = resolveGeneratedPath(root, srcDir, options.imageTypesOutFile, false);
|
|
21941
|
+
if (options.check) {
|
|
21942
|
+
checkGeneratedFile(imageTypesPath, createFarmImageTypeDeclarations(), result.stalePaths);
|
|
21943
|
+
result.imageTypesPath = imageTypesPath;
|
|
21944
|
+
} else {
|
|
21945
|
+
result.imageTypesPath = generateFarmImageTypes({
|
|
21946
|
+
root,
|
|
21947
|
+
srcDir,
|
|
21948
|
+
outFile: options.imageTypesOutFile
|
|
21949
|
+
});
|
|
21950
|
+
}
|
|
21777
21951
|
}
|
|
21778
21952
|
if (shouldRefreshUnifiedTypes && options.i18nConfig?.enabled && !options.i18nTypesOutFile) {
|
|
21779
21953
|
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
21780
21954
|
unifiedSections.push(renderFarmI18nTypes(options.i18nConfig.locales, signatures));
|
|
21781
21955
|
result.i18nTypesPath = unifiedTypesPath;
|
|
21782
21956
|
} else if (shouldGenerateI18n && options.i18nConfig) {
|
|
21783
|
-
|
|
21784
|
-
root,
|
|
21785
|
-
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
21957
|
+
if (options.check) {
|
|
21958
|
+
const i18nTypesPath = resolveGeneratedPath(root, srcDir, options.i18nTypesOutFile, false);
|
|
21959
|
+
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
21960
|
+
checkGeneratedFile(
|
|
21961
|
+
i18nTypesPath,
|
|
21962
|
+
renderFarmI18nTypes(options.i18nConfig.locales, signatures),
|
|
21963
|
+
result.stalePaths
|
|
21964
|
+
);
|
|
21965
|
+
result.i18nTypesPath = i18nTypesPath;
|
|
21966
|
+
} else {
|
|
21967
|
+
result.i18nTypesPath = await generateFarmI18nTypes({
|
|
21968
|
+
root,
|
|
21969
|
+
srcDir,
|
|
21970
|
+
config: options.i18nConfig,
|
|
21971
|
+
outFile: options.i18nTypesOutFile
|
|
21972
|
+
});
|
|
21973
|
+
}
|
|
21789
21974
|
}
|
|
21790
21975
|
if (shouldRefreshUnifiedTypes) {
|
|
21791
|
-
(
|
|
21792
|
-
writeFileIfChanged(
|
|
21976
|
+
writeOrCheckGeneratedFile(
|
|
21793
21977
|
unifiedTypesPath,
|
|
21794
21978
|
`/**
|
|
21795
21979
|
* Generated by Farm.js. Do not edit.
|
|
@@ -21798,14 +21982,41 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21798
21982
|
|
|
21799
21983
|
import "@farm.js/core/image";
|
|
21800
21984
|
|
|
21801
|
-
${unifiedSections.join("\n")}
|
|
21985
|
+
${unifiedSections.map((section) => section.trimEnd()).join("\n\n")}
|
|
21986
|
+
`,
|
|
21987
|
+
options.check,
|
|
21988
|
+
result.stalePaths
|
|
21802
21989
|
);
|
|
21803
21990
|
result.typesPath = unifiedTypesPath;
|
|
21804
|
-
|
|
21991
|
+
if (options.check) {
|
|
21992
|
+
collectLegacyTypeArtifacts(root, srcDir, result.stalePaths);
|
|
21993
|
+
} else {
|
|
21994
|
+
removeLegacyTypeArtifacts(root, srcDir);
|
|
21995
|
+
}
|
|
21805
21996
|
}
|
|
21806
21997
|
return result;
|
|
21807
21998
|
}
|
|
21808
21999
|
__name(generateFarmTypeArtifacts, "generateFarmTypeArtifacts");
|
|
22000
|
+
function resolveGeneratedPath(root, srcDir, outFile, relativeToSrc = true) {
|
|
22001
|
+
if ((0, import_path8.isAbsolute)(outFile)) return (0, import_path8.resolve)(outFile);
|
|
22002
|
+
return (0, import_path8.resolve)(root, relativeToSrc ? (0, import_path8.join)(srcDir, outFile) : outFile);
|
|
22003
|
+
}
|
|
22004
|
+
__name(resolveGeneratedPath, "resolveGeneratedPath");
|
|
22005
|
+
function writeOrCheckGeneratedFile(filePath, content, check, stalePaths) {
|
|
22006
|
+
if (check) {
|
|
22007
|
+
checkGeneratedFile(filePath, content, stalePaths);
|
|
22008
|
+
return;
|
|
22009
|
+
}
|
|
22010
|
+
(0, import_fs4.mkdirSync)((0, import_path8.dirname)(filePath), { recursive: true });
|
|
22011
|
+
writeFileIfChanged(filePath, content);
|
|
22012
|
+
}
|
|
22013
|
+
__name(writeOrCheckGeneratedFile, "writeOrCheckGeneratedFile");
|
|
22014
|
+
function checkGeneratedFile(filePath, content, stalePaths) {
|
|
22015
|
+
if (!(0, import_fs4.existsSync)(filePath) || (0, import_fs4.readFileSync)(filePath, "utf8") !== content) {
|
|
22016
|
+
stalePaths.push(filePath);
|
|
22017
|
+
}
|
|
22018
|
+
}
|
|
22019
|
+
__name(checkGeneratedFile, "checkGeneratedFile");
|
|
21809
22020
|
var LEGACY_TYPE_ARTIFACTS = [
|
|
21810
22021
|
["farm-routes.d.ts", "Auto-generated route types"],
|
|
21811
22022
|
["farm-env.d.ts", "Auto-generated env types"],
|
|
@@ -21823,6 +22034,14 @@ function removeLegacyTypeArtifacts(root, srcDir) {
|
|
|
21823
22034
|
}
|
|
21824
22035
|
}
|
|
21825
22036
|
__name(removeLegacyTypeArtifacts, "removeLegacyTypeArtifacts");
|
|
22037
|
+
function collectLegacyTypeArtifacts(root, srcDir, stalePaths) {
|
|
22038
|
+
for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
|
|
22039
|
+
const filePath = (0, import_path8.join)(root, srcDir, fileName);
|
|
22040
|
+
if (!(0, import_fs4.existsSync)(filePath)) continue;
|
|
22041
|
+
if ((0, import_fs4.readFileSync)(filePath, "utf8").includes(marker)) stalePaths.push(filePath);
|
|
22042
|
+
}
|
|
22043
|
+
}
|
|
22044
|
+
__name(collectLegacyTypeArtifacts, "collectLegacyTypeArtifacts");
|
|
21826
22045
|
|
|
21827
22046
|
// src/vite.ts
|
|
21828
22047
|
init_markdown();
|
|
@@ -22178,7 +22397,7 @@ function transformError(id, message) {
|
|
|
22178
22397
|
__name(transformError, "transformError");
|
|
22179
22398
|
|
|
22180
22399
|
// package.json
|
|
22181
|
-
var version = "0.1.0-beta.
|
|
22400
|
+
var version = "0.1.0-beta.17";
|
|
22182
22401
|
|
|
22183
22402
|
// src/version.ts
|
|
22184
22403
|
var FARM_VERSION = version;
|
|
@@ -22414,6 +22633,12 @@ function createFarmClientOptimizeDepsConfig(entries) {
|
|
|
22414
22633
|
};
|
|
22415
22634
|
}
|
|
22416
22635
|
__name(createFarmClientOptimizeDepsConfig, "createFarmClientOptimizeDepsConfig");
|
|
22636
|
+
function createFarmSourceAlias(projectRoot, srcDir = "src") {
|
|
22637
|
+
return {
|
|
22638
|
+
"@": import_node_path9.default.resolve(projectRoot, srcDir)
|
|
22639
|
+
};
|
|
22640
|
+
}
|
|
22641
|
+
__name(createFarmSourceAlias, "createFarmSourceAlias");
|
|
22417
22642
|
|
|
22418
22643
|
// src/vite.ts
|
|
22419
22644
|
init_fonts();
|
|
@@ -26172,7 +26397,7 @@ async function defineConfig2(config = {}) {
|
|
|
26172
26397
|
// Stub out problematic server-only modules during dev mode
|
|
26173
26398
|
alias: {
|
|
26174
26399
|
...getFarmLayerAliases(config.layers),
|
|
26175
|
-
|
|
26400
|
+
...createFarmSourceAlias(appRoot, config.srcDir),
|
|
26176
26401
|
// Nitro internals that should not be resolved in browser
|
|
26177
26402
|
"supports-color": "data:text/javascript,export default false; export const supportsColor = false; export const stdout = false; export const stderr = false;",
|
|
26178
26403
|
"@poppinss/dumper": "data:text/javascript,export default {};",
|