@farm.js/core 0.1.17 → 0.1.18
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.cjs +12 -225
- package/dist/agent-runtime.cjs +83 -2800
- package/dist/api/client.cjs +17 -4060
- package/dist/api/route-manager.cjs +34 -4354
- package/dist/api/runtime.cjs +29 -2696
- package/dist/api.cjs +88 -8434
- package/dist/app-markdown.cjs +39 -280
- package/dist/cache.cjs +38 -1560
- package/dist/chunk-22GUSVNJ.cjs +351 -0
- package/dist/chunk-2CQ74SP6.cjs +13 -0
- package/dist/chunk-2SJ4RQ6P.cjs +57 -0
- package/dist/chunk-3376ZTRC.cjs +1 -0
- package/dist/{chunk-YD4J4XCI.mjs → chunk-3XG26Z3J.mjs} +1 -1
- package/dist/chunk-4PNUXIVU.cjs +472 -0
- package/dist/chunk-4PPEPOZZ.cjs +21 -0
- package/dist/chunk-4ZFL5GFN.cjs +520 -0
- package/dist/chunk-5OVTOKGH.cjs +65 -0
- package/dist/chunk-5QIKR7RR.cjs +224 -0
- package/dist/chunk-5ZSWG4UX.cjs +127 -0
- package/dist/chunk-62YJ2IEB.cjs +238 -0
- package/dist/chunk-6EODJYCX.cjs +183 -0
- package/dist/chunk-6EXBPJ24.cjs +434 -0
- package/dist/chunk-6QQDAAAZ.cjs +38 -0
- package/dist/chunk-6V4TDWEC.cjs +455 -0
- package/dist/chunk-72ADZ6GQ.cjs +19 -0
- package/dist/chunk-75BRBIFP.cjs +172 -0
- package/dist/chunk-7W3CPVXS.cjs +24 -0
- package/dist/chunk-A6WIQH5Z.cjs +31 -0
- package/dist/chunk-AFOD3LYZ.cjs +377 -0
- package/dist/chunk-AMDMVWMI.cjs +39 -0
- package/dist/chunk-AORPIPNB.cjs +552 -0
- package/dist/chunk-ARJWXNQL.cjs +256 -0
- package/dist/chunk-AWRISO2H.cjs +2199 -0
- package/dist/chunk-AYJR42WX.cjs +711 -0
- package/dist/chunk-B4CH33IG.cjs +644 -0
- package/dist/chunk-BIDYX3SL.cjs +91 -0
- package/dist/chunk-BSTRERPP.cjs +40 -0
- package/dist/chunk-BYODCJD6.cjs +663 -0
- package/dist/chunk-C3VRMB6H.cjs +85 -0
- package/dist/chunk-C5GUTBZK.cjs +173 -0
- package/dist/chunk-CIAGU2X4.cjs +337 -0
- package/dist/chunk-CMGMGHUZ.cjs +27 -0
- package/dist/chunk-CXP5U3RW.cjs +54 -0
- package/dist/chunk-D2ULAULS.cjs +166 -0
- package/dist/chunk-D7JTOLFK.cjs +285 -0
- package/dist/chunk-DVM4FKZL.cjs +169 -0
- package/dist/chunk-DYEJQTDN.cjs +49 -0
- package/dist/chunk-E2BMSZ2W.cjs +151 -0
- package/dist/chunk-E3UK5IIB.cjs +593 -0
- package/dist/chunk-EM6SBQKM.cjs +470 -0
- package/dist/chunk-FJSWYIR7.cjs +482 -0
- package/dist/chunk-FK6GO24V.cjs +54 -0
- package/dist/chunk-FXUUWYAX.cjs +654 -0
- package/dist/chunk-G3HRIVEY.cjs +395 -0
- package/dist/chunk-G643DQCH.cjs +13 -0
- package/dist/chunk-G7HXGLEC.cjs +175 -0
- package/dist/chunk-GDSHDTJ4.cjs +152 -0
- package/dist/chunk-GNEO2XOF.cjs +2040 -0
- package/dist/{chunk-56DAX2BE.mjs → chunk-GYKJCFTS.mjs} +1 -1
- package/dist/chunk-H6G5INWM.cjs +1094 -0
- package/dist/chunk-HBTUGXHS.cjs +180 -0
- package/dist/chunk-HREOKQWT.cjs +45 -0
- package/dist/chunk-I4J452B7.cjs +435 -0
- package/dist/chunk-I57LW5VZ.cjs +94 -0
- package/dist/chunk-I7PUUDGY.cjs +389 -0
- package/dist/chunk-IAMRBF3Z.cjs +86 -0
- package/dist/chunk-IKNRN4VS.cjs +14214 -0
- package/dist/chunk-IQXFRNY2.cjs +169 -0
- package/dist/chunk-IXTFU4PL.cjs +2355 -0
- package/dist/chunk-J2OP5GG3.cjs +725 -0
- package/dist/chunk-J3LOGE4T.cjs +42 -0
- package/dist/chunk-J7FSKED3.cjs +93 -0
- package/dist/chunk-JDNHKPTD.cjs +22 -0
- package/dist/chunk-JSROZYYO.cjs +164 -0
- package/dist/chunk-K6FNHVDR.cjs +696 -0
- package/dist/chunk-KGZIORNL.cjs +43 -0
- package/dist/{chunk-MVIWBEJF.mjs → chunk-KPNVGRBL.mjs} +1 -1
- package/dist/chunk-KR6CKSXT.cjs +15 -0
- package/dist/chunk-KROWKCUH.cjs +185 -0
- package/dist/chunk-KVFPGF2M.cjs +46 -0
- package/dist/chunk-LCCBO7PJ.cjs +46 -0
- package/dist/chunk-LIUGYUX3.cjs +22 -0
- package/dist/chunk-LTNGXMQ6.cjs +55 -0
- package/dist/chunk-M2L4MYDQ.cjs +14 -0
- package/dist/chunk-MCJLA63J.cjs +1 -0
- package/dist/chunk-MKB2EGIR.cjs +148 -0
- package/dist/chunk-MQ3H6LT5.cjs +202 -0
- package/dist/chunk-MT763TDW.cjs +43 -0
- package/dist/chunk-MWSK6C4J.cjs +18 -0
- package/dist/chunk-MWWVKDW3.cjs +169 -0
- package/dist/chunk-NO3WWW3N.cjs +192 -0
- package/dist/chunk-NV3A5DXM.cjs +862 -0
- package/dist/chunk-NWOD6NIT.cjs +9 -0
- package/dist/chunk-NZKJGRB3.cjs +230 -0
- package/dist/chunk-OAVTUMJP.cjs +1496 -0
- package/dist/chunk-OHY2ZWUG.cjs +25 -0
- package/dist/chunk-OI6CMLWX.cjs +47 -0
- package/dist/chunk-OIEOCXKG.cjs +453 -0
- package/dist/chunk-OWOUTKIJ.cjs +558 -0
- package/dist/chunk-OX6O6WVA.cjs +74 -0
- package/dist/chunk-OXSIH4D6.cjs +476 -0
- package/dist/chunk-OYEUREB6.cjs +35 -0
- package/dist/chunk-PCOTGFSM.cjs +139 -0
- package/dist/chunk-PZYCPSCC.cjs +35 -0
- package/dist/chunk-QBK2AA4U.cjs +445 -0
- package/dist/chunk-QBPXNZGV.cjs +487 -0
- package/dist/chunk-QNPEUFHQ.cjs +27 -0
- package/dist/chunk-QZRVZSPN.cjs +236 -0
- package/dist/chunk-R5A5KNVX.cjs +20 -0
- package/dist/chunk-R5JIFR6B.cjs +42 -0
- package/dist/chunk-R6AIILII.cjs +193 -0
- package/dist/chunk-RG3ZOTG5.cjs +34 -0
- package/dist/chunk-ROUTX2E5.cjs +390 -0
- package/dist/chunk-RTHIVJ2G.cjs +54 -0
- package/dist/chunk-S3A45T7F.cjs +166 -0
- package/dist/chunk-S3JO3N4H.cjs +17 -0
- package/dist/chunk-SK35NQKK.cjs +27 -0
- package/dist/chunk-SU7MH53P.cjs +180 -0
- package/dist/chunk-SVRTJOUF.cjs +113 -0
- package/dist/chunk-SWN467MP.cjs +18 -0
- package/dist/chunk-SYQ3MOWW.cjs +73 -0
- package/dist/chunk-T5CERMEH.cjs +417 -0
- package/dist/chunk-TFAXUHWX.cjs +206 -0
- package/dist/chunk-TIWHTW3Q.cjs +24 -0
- package/dist/chunk-TKJZFIML.cjs +20 -0
- package/dist/chunk-TKNSDBBN.cjs +193 -0
- package/dist/chunk-TWGMSEHX.cjs +525 -0
- package/dist/chunk-TYQUSXUG.cjs +1357 -0
- package/dist/chunk-U4KT7QP3.cjs +23 -0
- package/dist/chunk-UJ2C4ICS.cjs +277 -0
- package/dist/chunk-UN5GHC5V.cjs +10244 -0
- package/dist/chunk-UQZ4AYTH.cjs +168 -0
- package/dist/chunk-US2QVW3E.cjs +36 -0
- package/dist/chunk-VB6UCX3V.cjs +421 -0
- package/dist/chunk-VEKFLAQM.cjs +300 -0
- package/dist/chunk-VQDBNVOO.cjs +14 -0
- package/dist/chunk-W4E7WMXE.cjs +71 -0
- package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
- package/dist/chunk-WMAPPDMM.cjs +28 -0
- package/dist/chunk-WMOGFOUJ.cjs +223 -0
- package/dist/chunk-WPYFSQKK.cjs +37 -0
- package/dist/chunk-WZMNW2IW.cjs +1415 -0
- package/dist/chunk-XGC343EY.cjs +443 -0
- package/dist/chunk-XSKZORAS.cjs +727 -0
- package/dist/chunk-XWAWFQFS.cjs +82 -0
- package/dist/chunk-Y4YMF2NQ.cjs +460 -0
- package/dist/chunk-Y4YWHNKU.cjs +250 -0
- package/dist/chunk-Y53ZSFN6.cjs +504 -0
- package/dist/chunk-YA6LLTIJ.cjs +411 -0
- package/dist/chunk-YFPGHF5F.cjs +202 -0
- package/dist/chunk-YJRZR7VU.cjs +28 -0
- package/dist/chunk-YTAABQEV.cjs +1 -0
- package/dist/chunk-YX3DBN4M.cjs +18 -0
- package/dist/chunk-YZTASLPQ.cjs +64 -0
- package/dist/chunk-Z5HIWVDP.cjs +2173 -0
- package/dist/chunk-ZEG3OPIB.cjs +93 -0
- package/dist/chunk-ZMN3H73H.cjs +155 -0
- package/dist/client/lifecycle.cjs +6 -35
- package/dist/client-plugins.cjs +7 -448
- package/dist/client.cjs +171 -9808
- package/dist/config.cjs +8 -36
- package/dist/cron.cjs +24 -491
- package/dist/deferred.cjs +26 -475
- package/dist/deployment.cjs +39 -210
- package/dist/devtools-OUIPHVV6.cjs +388 -0
- package/dist/devtools-client-4WAPJY5L.cjs +254 -0
- package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
- package/dist/docs.cjs +46 -5657
- package/dist/env-types.cjs +5 -226
- package/dist/env.cjs +21 -338
- package/dist/environment/vite.cjs +8 -372
- package/dist/environment.cjs +12 -94
- package/dist/font.cjs +13 -63
- package/dist/headers.cjs +7 -123
- package/dist/i18n/client.cjs +55 -294
- package/dist/i18n/index.cjs +22 -209
- package/dist/i18n/server.cjs +22 -745
- package/dist/image/server.cjs +13 -729
- package/dist/image/sharp.cjs +33 -171
- package/dist/image.cjs +41 -85
- package/dist/index.cjs +1151 -68080
- package/dist/index.mjs +3 -3
- package/dist/instrumentation.cjs +12 -138
- package/dist/integration-orm-55F7CII5.cjs +13 -0
- package/dist/integrations.cjs +55 -4090
- package/dist/internal/app-markdown-runtime.cjs +27 -224
- package/dist/internal/build-runtime.cjs +120 -52259
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/internal/cli-runtime.cjs +67 -13811
- package/dist/internal/client-error-overlay.cjs +80 -733
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +81 -913
- package/dist/internal/compression-runtime.cjs +8 -214
- package/dist/internal/config-runtime.cjs +42 -6547
- package/dist/internal/docs-precompiled-runtime.cjs +26 -46
- package/dist/internal/infra-analytics-runtime.cjs +10 -536
- package/dist/internal/isolated-boundary.cjs +14 -414
- package/dist/internal/metadata-image-runtime.cjs +7 -285
- package/dist/internal/product-telemetry-runtime.cjs +42 -97
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +6 -63
- package/dist/internal/production-runtime.cjs +418 -7133
- package/dist/internal/request-cookies.cjs +6 -54
- package/dist/json-ld.cjs +24 -50
- package/dist/layers-E4WPJNY5.cjs +17 -0
- package/dist/manager-G4B2IPYE.cjs +14 -0
- package/dist/markdown.cjs +21 -547
- package/dist/middleware.cjs +36 -2995
- package/dist/navigation.cjs +22 -2588
- package/dist/nitro-4I2MYLY2.cjs +652 -0
- package/dist/observability.cjs +22 -614
- package/dist/og.cjs +5 -28
- package/dist/plugin.cjs +106 -37442
- package/dist/plugin.mjs +2 -2
- package/dist/query/client.cjs +113 -449
- package/dist/query/index.cjs +26 -288
- package/dist/query/parsers.cjs +23 -247
- package/dist/query/server.cjs +36 -298
- package/dist/renderer/react/client.cjs +9 -43
- package/dist/renderer/react/server.cjs +40 -103
- package/dist/renderer/react/vite.cjs +7 -29
- package/dist/renderer-client.cjs +126 -4295
- package/dist/renderer.cjs +31 -249
- package/dist/request.cjs +5 -68
- package/dist/router.cjs +11 -474
- package/dist/routes.cjs +42 -2461
- package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
- package/dist/schema.cjs +6 -33
- package/dist/search-client-G3RICOFU.cjs +13 -0
- package/dist/server-action-security.cjs +25 -541
- package/dist/server-fn-client.cjs +6 -337
- package/dist/server-fn.cjs +32 -1841
- package/dist/server-plugins.cjs +15 -884
- package/dist/server-query-client.cjs +15 -1883
- package/dist/server-query.cjs +16 -1838
- package/dist/server.cjs +296 -44681
- package/dist/server.mjs +2 -2
- package/dist/storage.cjs +57 -576
- package/dist/testing.cjs +89 -3186
- package/dist/theme/client.cjs +13 -108
- package/dist/theme/index.cjs +6 -68
- package/dist/theme/runtime.cjs +13 -78
- package/dist/theme/server.cjs +10 -179
- package/dist/version.cjs +4 -32
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +119 -37773
- package/dist/vite.mjs +2 -2
- package/dist/workflows.cjs +19 -1040
- package/package.json +1 -1
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkNO3WWW3Ncjs = require('./chunk-NO3WWW3N.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
7
|
+
|
|
8
|
+
// src/request-context.ts
|
|
9
|
+
var REQUEST_CONTEXT_STORE_KEY = /* @__PURE__ */ Symbol.for("farm.requestContextStore");
|
|
10
|
+
function getRequestContextStore() {
|
|
11
|
+
const globalState = globalThis;
|
|
12
|
+
if (!globalState[REQUEST_CONTEXT_STORE_KEY]) {
|
|
13
|
+
globalState[REQUEST_CONTEXT_STORE_KEY] = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
}
|
|
15
|
+
return globalState[REQUEST_CONTEXT_STORE_KEY];
|
|
16
|
+
}
|
|
17
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getRequestContextStore, "getRequestContextStore");
|
|
18
|
+
function getBucket(target) {
|
|
19
|
+
const requestContextStore = getRequestContextStore();
|
|
20
|
+
let bucket = requestContextStore.get(target);
|
|
21
|
+
if (!bucket) {
|
|
22
|
+
bucket = {
|
|
23
|
+
privateData: /* @__PURE__ */ new Map(),
|
|
24
|
+
exposedData: /* @__PURE__ */ new Map()
|
|
25
|
+
};
|
|
26
|
+
requestContextStore.set(target, bucket);
|
|
27
|
+
}
|
|
28
|
+
return bucket;
|
|
29
|
+
}
|
|
30
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getBucket, "getBucket");
|
|
31
|
+
function setRequestContext(target, key, value, options = {}) {
|
|
32
|
+
const bucket = getBucket(target);
|
|
33
|
+
bucket.privateData.set(key, value);
|
|
34
|
+
if (options.exposeToPage) {
|
|
35
|
+
bucket.exposedData.set(key, value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, setRequestContext, "setRequestContext");
|
|
39
|
+
function getRequestContext(target, key) {
|
|
40
|
+
const requestContextStore = getRequestContextStore();
|
|
41
|
+
const bucket = requestContextStore.get(target);
|
|
42
|
+
return _optionalChain([bucket, 'optionalAccess', _ => _.privateData, 'access', _2 => _2.get, 'call', _3 => _3(key)]);
|
|
43
|
+
}
|
|
44
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getRequestContext, "getRequestContext");
|
|
45
|
+
function hasRequestContext(target, key) {
|
|
46
|
+
const requestContextStore = getRequestContextStore();
|
|
47
|
+
const bucket = requestContextStore.get(target);
|
|
48
|
+
return _nullishCoalesce(_optionalChain([bucket, 'optionalAccess', _4 => _4.privateData, 'access', _5 => _5.has, 'call', _6 => _6(key)]), () => ( false));
|
|
49
|
+
}
|
|
50
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, hasRequestContext, "hasRequestContext");
|
|
51
|
+
function deleteRequestContext(target, key) {
|
|
52
|
+
const requestContextStore = getRequestContextStore();
|
|
53
|
+
const bucket = requestContextStore.get(target);
|
|
54
|
+
if (!bucket) return false;
|
|
55
|
+
const removedPrivate = bucket.privateData.delete(key);
|
|
56
|
+
bucket.exposedData.delete(key);
|
|
57
|
+
return removedPrivate;
|
|
58
|
+
}
|
|
59
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, deleteRequestContext, "deleteRequestContext");
|
|
60
|
+
function clearRequestContext(target) {
|
|
61
|
+
const requestContextStore = getRequestContextStore();
|
|
62
|
+
const bucket = requestContextStore.get(target);
|
|
63
|
+
if (!bucket) return;
|
|
64
|
+
bucket.privateData.clear();
|
|
65
|
+
bucket.exposedData.clear();
|
|
66
|
+
}
|
|
67
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, clearRequestContext, "clearRequestContext");
|
|
68
|
+
function getRequestContextSnapshot(target, options = {}) {
|
|
69
|
+
const requestContextStore = getRequestContextStore();
|
|
70
|
+
const bucket = requestContextStore.get(target);
|
|
71
|
+
if (!bucket) return /* @__PURE__ */ new Map();
|
|
72
|
+
if (options.exposedOnly) {
|
|
73
|
+
return new Map(bucket.exposedData);
|
|
74
|
+
}
|
|
75
|
+
return new Map(bucket.privateData);
|
|
76
|
+
}
|
|
77
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getRequestContextSnapshot, "getRequestContextSnapshot");
|
|
78
|
+
function copyRequestContext(source, target) {
|
|
79
|
+
const bucket = getRequestContextStore().get(source);
|
|
80
|
+
if (!bucket || source === target) return;
|
|
81
|
+
for (const [key, value] of bucket.privateData) {
|
|
82
|
+
setRequestContext(target, key, value, { exposeToPage: bucket.exposedData.has(key) });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, copyRequestContext, "copyRequestContext");
|
|
86
|
+
|
|
87
|
+
// src/server-http.ts
|
|
88
|
+
function createFarmNodeRequestAbortSignal(req, res) {
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
let disposed = false;
|
|
91
|
+
const dispose = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
92
|
+
if (disposed) return;
|
|
93
|
+
disposed = true;
|
|
94
|
+
req.off("aborted", abort);
|
|
95
|
+
res.off("close", abortOnEarlyClose);
|
|
96
|
+
res.off("finish", dispose);
|
|
97
|
+
controller.signal.removeEventListener("abort", dispose);
|
|
98
|
+
}, "dispose");
|
|
99
|
+
const abort = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => controller.abort(), "abort");
|
|
100
|
+
const abortOnEarlyClose = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
101
|
+
if (!res.writableEnded) abort();
|
|
102
|
+
dispose();
|
|
103
|
+
}, "abortOnEarlyClose");
|
|
104
|
+
if (req.aborted) {
|
|
105
|
+
controller.abort();
|
|
106
|
+
return controller.signal;
|
|
107
|
+
}
|
|
108
|
+
req.once("aborted", abort);
|
|
109
|
+
res.once("close", abortOnEarlyClose);
|
|
110
|
+
res.once("finish", dispose);
|
|
111
|
+
controller.signal.addEventListener("abort", dispose, { once: true });
|
|
112
|
+
return controller.signal;
|
|
113
|
+
}
|
|
114
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmNodeRequestAbortSignal, "createFarmNodeRequestAbortSignal");
|
|
115
|
+
var DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT = 1e7;
|
|
116
|
+
var DEFAULT_FARM_SERVER_HEADERS_TIMEOUT = 6e4;
|
|
117
|
+
var DEFAULT_FARM_SERVER_REQUEST_TIMEOUT = 3e5;
|
|
118
|
+
var DEFAULT_FARM_SERVER_KEEP_ALIVE_TIMEOUT = 5e3;
|
|
119
|
+
var DEFAULT_FARM_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT = 3e4;
|
|
120
|
+
var MAX_FARM_SERVER_TIMEOUT = 2147483647;
|
|
121
|
+
function matchesFarmIfNoneMatch(value, etag) {
|
|
122
|
+
const expected = parseEntityTag(trimOptionalWhitespace(etag));
|
|
123
|
+
if (!expected) return false;
|
|
124
|
+
const values = Array.isArray(value) ? value : [value];
|
|
125
|
+
const combined = values.filter((header) => typeof header === "string").join(",");
|
|
126
|
+
const fieldValue = trimOptionalWhitespace(combined);
|
|
127
|
+
if (!fieldValue) return false;
|
|
128
|
+
if (fieldValue === "*") return true;
|
|
129
|
+
let matched = false;
|
|
130
|
+
let hasEntityTag = false;
|
|
131
|
+
for (const candidate of splitEntityTags(fieldValue)) {
|
|
132
|
+
const token = trimOptionalWhitespace(candidate);
|
|
133
|
+
if (!token) continue;
|
|
134
|
+
const parsed = parseEntityTag(token);
|
|
135
|
+
if (!parsed) return false;
|
|
136
|
+
hasEntityTag = true;
|
|
137
|
+
if (parsed === expected) matched = true;
|
|
138
|
+
}
|
|
139
|
+
return hasEntityTag && matched;
|
|
140
|
+
}
|
|
141
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, matchesFarmIfNoneMatch, "matchesFarmIfNoneMatch");
|
|
142
|
+
function trimOptionalWhitespace(value) {
|
|
143
|
+
return value.replace(/^[\t ]+|[\t ]+$/g, "");
|
|
144
|
+
}
|
|
145
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, trimOptionalWhitespace, "trimOptionalWhitespace");
|
|
146
|
+
function parseEntityTag(value) {
|
|
147
|
+
const opaqueTag = value.startsWith("W/") ? value.slice(2) : value;
|
|
148
|
+
if (opaqueTag.length < 2 || opaqueTag[0] !== '"' || opaqueTag.at(-1) !== '"') return null;
|
|
149
|
+
for (let index = 1; index < opaqueTag.length - 1; index++) {
|
|
150
|
+
const code = opaqueTag.charCodeAt(index);
|
|
151
|
+
if (code === 33 || code >= 35 && code <= 126 || code >= 128) continue;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return opaqueTag;
|
|
155
|
+
}
|
|
156
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parseEntityTag, "parseEntityTag");
|
|
157
|
+
function splitEntityTags(value) {
|
|
158
|
+
const tags = [];
|
|
159
|
+
let start = 0;
|
|
160
|
+
let quoted = false;
|
|
161
|
+
for (let index = 0; index < value.length; index++) {
|
|
162
|
+
const character = value[index];
|
|
163
|
+
if (character === '"') {
|
|
164
|
+
quoted = !quoted;
|
|
165
|
+
} else if (character === "," && !quoted) {
|
|
166
|
+
tags.push(value.slice(start, index));
|
|
167
|
+
start = index + 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
tags.push(value.slice(start));
|
|
171
|
+
return tags;
|
|
172
|
+
}
|
|
173
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, splitEntityTags, "splitEntityTags");
|
|
174
|
+
var _FarmRequestBodyError = class _FarmRequestBodyError extends Error {
|
|
175
|
+
constructor(code, status, message) {
|
|
176
|
+
super(message);
|
|
177
|
+
this.name = "FarmRequestBodyError";
|
|
178
|
+
this.code = code;
|
|
179
|
+
this.status = status;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmRequestBodyError, "FarmRequestBodyError");
|
|
183
|
+
var FarmRequestBodyError = _FarmRequestBodyError;
|
|
184
|
+
function resolveFarmServerConfig(config) {
|
|
185
|
+
const headersTimeout = parseFarmServerDuration(
|
|
186
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _7 => _7.headersTimeout]), () => ( DEFAULT_FARM_SERVER_HEADERS_TIMEOUT)),
|
|
187
|
+
"server.headersTimeout"
|
|
188
|
+
);
|
|
189
|
+
const requestTimeout = parseFarmServerDuration(
|
|
190
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _8 => _8.requestTimeout]), () => ( DEFAULT_FARM_SERVER_REQUEST_TIMEOUT)),
|
|
191
|
+
"server.requestTimeout"
|
|
192
|
+
);
|
|
193
|
+
if (headersTimeout > requestTimeout) {
|
|
194
|
+
throw new TypeError("server.headersTimeout must not exceed server.requestTimeout");
|
|
195
|
+
}
|
|
196
|
+
return Object.freeze({
|
|
197
|
+
bodySizeLimit: parseBodySizeLimit(
|
|
198
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _9 => _9.bodySizeLimit]), () => ( DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT)),
|
|
199
|
+
"server.bodySizeLimit"
|
|
200
|
+
),
|
|
201
|
+
trustProxy: _optionalChain([config, 'optionalAccess', _10 => _10.trustProxy]) === true,
|
|
202
|
+
headersTimeout,
|
|
203
|
+
requestTimeout,
|
|
204
|
+
keepAliveTimeout: parseFarmServerDuration(
|
|
205
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _11 => _11.keepAliveTimeout]), () => ( DEFAULT_FARM_SERVER_KEEP_ALIVE_TIMEOUT)),
|
|
206
|
+
"server.keepAliveTimeout"
|
|
207
|
+
),
|
|
208
|
+
gracefulShutdownTimeout: parseFarmServerDuration(
|
|
209
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _12 => _12.gracefulShutdownTimeout]), () => ( DEFAULT_FARM_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT)),
|
|
210
|
+
"server.gracefulShutdownTimeout"
|
|
211
|
+
),
|
|
212
|
+
health: resolveFarmServerHealthConfig(_optionalChain([config, 'optionalAccess', _13 => _13.health]))
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmServerConfig, "resolveFarmServerConfig");
|
|
216
|
+
function parseFarmServerDuration(value, optionName = "duration") {
|
|
217
|
+
if (typeof value === "number") {
|
|
218
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
219
|
+
throw new TypeError(`${optionName} must be a positive safe integer`);
|
|
220
|
+
}
|
|
221
|
+
if (value > MAX_FARM_SERVER_TIMEOUT) {
|
|
222
|
+
throw new TypeError(`${optionName} must not exceed ${MAX_FARM_SERVER_TIMEOUT} milliseconds`);
|
|
223
|
+
}
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
const match = value.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)$/);
|
|
227
|
+
if (!match) {
|
|
228
|
+
throw new TypeError(`${optionName} must be milliseconds or a duration such as "30s" or "2m"`);
|
|
229
|
+
}
|
|
230
|
+
const amount = Number(match[1]);
|
|
231
|
+
const unit = match[2];
|
|
232
|
+
const multiplier = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5;
|
|
233
|
+
const milliseconds = Math.floor(amount * multiplier);
|
|
234
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) {
|
|
235
|
+
throw new TypeError(`${optionName} must resolve to a positive safe integer`);
|
|
236
|
+
}
|
|
237
|
+
if (milliseconds > MAX_FARM_SERVER_TIMEOUT) {
|
|
238
|
+
throw new TypeError(`${optionName} must not exceed ${MAX_FARM_SERVER_TIMEOUT} milliseconds`);
|
|
239
|
+
}
|
|
240
|
+
return milliseconds;
|
|
241
|
+
}
|
|
242
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parseFarmServerDuration, "parseFarmServerDuration");
|
|
243
|
+
function resolveFarmServerHealthConfig(config) {
|
|
244
|
+
if (config === false || config && "enabled" in config && config.enabled === false) {
|
|
245
|
+
return Object.freeze({
|
|
246
|
+
enabled: false,
|
|
247
|
+
livenessPath: "/_farm/health/live",
|
|
248
|
+
readinessPath: "/_farm/health/ready"
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
const livenessPath = normalizeHealthPath(
|
|
252
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _14 => _14.livenessPath]), () => ( "/_farm/health/live")),
|
|
253
|
+
"server.health.livenessPath"
|
|
254
|
+
);
|
|
255
|
+
const readinessPath = normalizeHealthPath(
|
|
256
|
+
_nullishCoalesce(_optionalChain([config, 'optionalAccess', _15 => _15.readinessPath]), () => ( "/_farm/health/ready")),
|
|
257
|
+
"server.health.readinessPath"
|
|
258
|
+
);
|
|
259
|
+
if (livenessPath === readinessPath) {
|
|
260
|
+
throw new TypeError("server.health livenessPath and readinessPath must be different");
|
|
261
|
+
}
|
|
262
|
+
return Object.freeze({ enabled: true, livenessPath, readinessPath });
|
|
263
|
+
}
|
|
264
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmServerHealthConfig, "resolveFarmServerHealthConfig");
|
|
265
|
+
function normalizeHealthPath(value, optionName) {
|
|
266
|
+
const path = value.trim();
|
|
267
|
+
if (!path.startsWith("/") || path.includes("?") || path.includes("#") || path.includes("*")) {
|
|
268
|
+
throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
|
|
269
|
+
}
|
|
270
|
+
const normalized = path.length > 1 ? path.replace(/\/+$/, "") || "/" : path;
|
|
271
|
+
_chunkNO3WWW3Ncjs.assertBrowserStableRoutePath.call(void 0, normalized);
|
|
272
|
+
return normalized;
|
|
273
|
+
}
|
|
274
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, normalizeHealthPath, "normalizeHealthPath");
|
|
275
|
+
function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
|
|
276
|
+
if (typeof value === "number") {
|
|
277
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
278
|
+
throw new TypeError(`${optionName} must be a positive safe integer`);
|
|
279
|
+
}
|
|
280
|
+
return value;
|
|
281
|
+
}
|
|
282
|
+
const match = value.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|kib|mib|gib)?$/);
|
|
283
|
+
if (!match) {
|
|
284
|
+
throw new TypeError(`${optionName} must be bytes or a size string such as "500kb" or "10mb"`);
|
|
285
|
+
}
|
|
286
|
+
const amount = Number(match[1]);
|
|
287
|
+
const unit = _nullishCoalesce(match[2], () => ( "b"));
|
|
288
|
+
const multiplier = {
|
|
289
|
+
b: 1,
|
|
290
|
+
kb: 1e3,
|
|
291
|
+
mb: 1e6,
|
|
292
|
+
gb: 1e9,
|
|
293
|
+
kib: 1024,
|
|
294
|
+
mib: 1048576,
|
|
295
|
+
gib: 1073741824
|
|
296
|
+
};
|
|
297
|
+
const bytes = Math.floor(amount * multiplier[unit]);
|
|
298
|
+
if (!Number.isSafeInteger(bytes) || bytes <= 0) {
|
|
299
|
+
throw new TypeError(`${optionName} must resolve to a positive safe integer`);
|
|
300
|
+
}
|
|
301
|
+
return bytes;
|
|
302
|
+
}
|
|
303
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parseBodySizeLimit, "parseBodySizeLimit");
|
|
304
|
+
function cloneFarmRequestWithContext(request) {
|
|
305
|
+
const cloned = request.clone();
|
|
306
|
+
copyRequestContext(request, cloned);
|
|
307
|
+
return cloned;
|
|
308
|
+
}
|
|
309
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, cloneFarmRequestWithContext, "cloneFarmRequestWithContext");
|
|
310
|
+
async function bufferFarmRequestBody(request, limit) {
|
|
311
|
+
if (request.method === "GET" || request.method === "HEAD" || request.body === null) {
|
|
312
|
+
return request;
|
|
313
|
+
}
|
|
314
|
+
const bytes = await readFarmRequestBody(request, limit);
|
|
315
|
+
const body = new Uint8Array(bytes.byteLength);
|
|
316
|
+
body.set(bytes);
|
|
317
|
+
const buffered = new Request(request, {
|
|
318
|
+
// oxlint-disable-next-line unicorn/no-invalid-fetch-options -- GET and HEAD return above.
|
|
319
|
+
body: body.buffer
|
|
320
|
+
});
|
|
321
|
+
copyRequestContext(request, buffered);
|
|
322
|
+
return buffered;
|
|
323
|
+
}
|
|
324
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, bufferFarmRequestBody, "bufferFarmRequestBody");
|
|
325
|
+
async function readFarmRequestBody(request, limit) {
|
|
326
|
+
try {
|
|
327
|
+
validateContentLength(request.headers.get("content-length"), limit);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
void _optionalChain([request, 'access', _16 => _16.body, 'optionalAccess', _17 => _17.cancel, 'call', _18 => _18(error), 'access', _19 => _19.catch, 'call', _20 => _20(() => {
|
|
330
|
+
})]);
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
throwIfAborted(request.signal);
|
|
334
|
+
if (!request.body) return new Uint8Array();
|
|
335
|
+
const reader = request.body.getReader();
|
|
336
|
+
const chunks = [];
|
|
337
|
+
let total = 0;
|
|
338
|
+
const cancelBodyRead = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
339
|
+
void reader.cancel(request.signal.reason).catch(() => {
|
|
340
|
+
});
|
|
341
|
+
}, "cancelBodyRead");
|
|
342
|
+
request.signal.addEventListener("abort", cancelBodyRead, { once: true });
|
|
343
|
+
try {
|
|
344
|
+
while (true) {
|
|
345
|
+
throwIfAborted(request.signal);
|
|
346
|
+
const { done, value } = await reader.read();
|
|
347
|
+
throwIfAborted(request.signal);
|
|
348
|
+
if (done) break;
|
|
349
|
+
if (!value) continue;
|
|
350
|
+
total += value.byteLength;
|
|
351
|
+
if (total > limit) {
|
|
352
|
+
const error = new FarmRequestBodyError("BODY_TOO_LARGE", 413, "Request body is too large");
|
|
353
|
+
void reader.cancel(error).catch(() => {
|
|
354
|
+
});
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
chunks.push(value);
|
|
358
|
+
}
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (request.signal.aborted) throwIfAborted(request.signal);
|
|
361
|
+
throw error;
|
|
362
|
+
} finally {
|
|
363
|
+
request.signal.removeEventListener("abort", cancelBodyRead);
|
|
364
|
+
reader.releaseLock();
|
|
365
|
+
}
|
|
366
|
+
const body = new Uint8Array(total);
|
|
367
|
+
let offset = 0;
|
|
368
|
+
for (const chunk of chunks) {
|
|
369
|
+
body.set(chunk, offset);
|
|
370
|
+
offset += chunk.byteLength;
|
|
371
|
+
}
|
|
372
|
+
return body;
|
|
373
|
+
}
|
|
374
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readFarmRequestBody, "readFarmRequestBody");
|
|
375
|
+
async function readNodeRequestBody(request, limit) {
|
|
376
|
+
const rawContentLength = request.headers["content-length"];
|
|
377
|
+
const contentLength = Array.isArray(rawContentLength) ? rawContentLength[0] : rawContentLength;
|
|
378
|
+
try {
|
|
379
|
+
validateContentLength(contentLength, limit);
|
|
380
|
+
} catch (error) {
|
|
381
|
+
_optionalChain([request, 'access', _21 => _21.resume, 'optionalCall', _22 => _22()]);
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
return await new Promise((resolve, reject) => {
|
|
385
|
+
const chunks = [];
|
|
386
|
+
let total = 0;
|
|
387
|
+
let settled = false;
|
|
388
|
+
const cleanup = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
389
|
+
_optionalChain([request, 'access', _23 => _23.removeListener, 'optionalCall', _24 => _24("data", onData)]);
|
|
390
|
+
_optionalChain([request, 'access', _25 => _25.removeListener, 'optionalCall', _26 => _26("end", onEnd)]);
|
|
391
|
+
_optionalChain([request, 'access', _27 => _27.removeListener, 'optionalCall', _28 => _28("error", onError)]);
|
|
392
|
+
}, "cleanup");
|
|
393
|
+
const rejectOnce = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (error) => {
|
|
394
|
+
if (settled) return;
|
|
395
|
+
settled = true;
|
|
396
|
+
cleanup();
|
|
397
|
+
_optionalChain([request, 'access', _29 => _29.resume, 'optionalCall', _30 => _30()]);
|
|
398
|
+
reject(error);
|
|
399
|
+
}, "rejectOnce");
|
|
400
|
+
const onData = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (chunk) => {
|
|
401
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
402
|
+
total += bytes.byteLength;
|
|
403
|
+
if (total > limit) {
|
|
404
|
+
rejectOnce(new FarmRequestBodyError("BODY_TOO_LARGE", 413, "Request body is too large"));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
chunks.push(bytes);
|
|
408
|
+
}, "onData");
|
|
409
|
+
const onEnd = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
|
|
410
|
+
if (settled) return;
|
|
411
|
+
settled = true;
|
|
412
|
+
cleanup();
|
|
413
|
+
resolve(Buffer.concat(chunks, total));
|
|
414
|
+
}, "onEnd");
|
|
415
|
+
const onError = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (error) => rejectOnce(error), "onError");
|
|
416
|
+
request.on("data", onData);
|
|
417
|
+
request.on("end", onEnd);
|
|
418
|
+
request.on("error", onError);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readNodeRequestBody, "readNodeRequestBody");
|
|
422
|
+
function createFarmRequestBodyErrorResponse(error) {
|
|
423
|
+
if (!(error instanceof FarmRequestBodyError)) return null;
|
|
424
|
+
return new Response(error.status === 413 ? "Payload Too Large" : "Bad Request", {
|
|
425
|
+
status: error.status,
|
|
426
|
+
headers: {
|
|
427
|
+
"cache-control": "no-store",
|
|
428
|
+
"content-type": "text/plain; charset=utf-8",
|
|
429
|
+
"x-content-type-options": "nosniff"
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmRequestBodyErrorResponse, "createFarmRequestBodyErrorResponse");
|
|
434
|
+
function validateContentLength(value, limit) {
|
|
435
|
+
const contentLength = _optionalChain([value, 'optionalAccess', _31 => _31.trim, 'call', _32 => _32()]);
|
|
436
|
+
if (!contentLength) return;
|
|
437
|
+
if (!/^\d+$/.test(contentLength)) {
|
|
438
|
+
throw new FarmRequestBodyError("INVALID_CONTENT_LENGTH", 400, "Invalid content-length header");
|
|
439
|
+
}
|
|
440
|
+
if (Number(contentLength) > limit) {
|
|
441
|
+
throw new FarmRequestBodyError("BODY_TOO_LARGE", 413, "Request body is too large");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateContentLength, "validateContentLength");
|
|
445
|
+
function throwIfAborted(signal) {
|
|
446
|
+
if (!signal.aborted) return;
|
|
447
|
+
if (signal.reason !== void 0) throw signal.reason;
|
|
448
|
+
throw new DOMException("The operation was aborted", "AbortError");
|
|
449
|
+
}
|
|
450
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, throwIfAborted, "throwIfAborted");
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
exports.setRequestContext = setRequestContext; exports.getRequestContext = getRequestContext; exports.hasRequestContext = hasRequestContext; exports.deleteRequestContext = deleteRequestContext; exports.clearRequestContext = clearRequestContext; exports.getRequestContextSnapshot = getRequestContextSnapshot; exports.copyRequestContext = copyRequestContext; exports.createFarmNodeRequestAbortSignal = createFarmNodeRequestAbortSignal; exports.DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT = DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT; exports.matchesFarmIfNoneMatch = matchesFarmIfNoneMatch; exports.resolveFarmServerConfig = resolveFarmServerConfig; exports.parseBodySizeLimit = parseBodySizeLimit; exports.cloneFarmRequestWithContext = cloneFarmRequestWithContext; exports.bufferFarmRequestBody = bufferFarmRequestBody; exports.readFarmRequestBody = readFarmRequestBody; exports.readNodeRequestBody = readNodeRequestBody; exports.createFarmRequestBodyErrorResponse = createFarmRequestBodyErrorResponse;
|