@farm.js/core 0.1.27 → 0.1.29
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/agent-runtime.d.mts +3 -2
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/api/client.cjs +4 -6
- package/dist/api/client.d.mts +1 -0
- package/dist/api/client.d.ts +1 -0
- package/dist/api/client.mjs +3 -5
- package/dist/api/route-manager.cjs +9 -8
- package/dist/api/route-manager.d.mts +2 -1
- package/dist/api/route-manager.d.ts +2 -1
- package/dist/api/route-manager.mjs +8 -7
- package/dist/api/runtime.cjs +7 -6
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/api/runtime.mjs +6 -5
- package/dist/api.cjs +12 -11
- package/dist/api.d.mts +19 -4
- package/dist/api.d.ts +19 -4
- package/dist/api.mjs +11 -10
- package/dist/{app-BfzZdjgX.d.mts → app-DAuUTIZf.d.mts} +3 -3
- package/dist/app-markdown.cjs +6 -5
- package/dist/app-markdown.d.mts +4 -3
- package/dist/app-markdown.d.ts +4 -3
- package/dist/app-markdown.mjs +5 -4
- package/dist/{app-CXK7Prrt.d.ts → app-sUJ3jnTZ.d.ts} +3 -3
- package/dist/cache-invalidation-BD0z_lfu.d.mts +4 -0
- package/dist/cache-invalidation-BD0z_lfu.d.ts +4 -0
- package/dist/cache.cjs +6 -4
- package/dist/cache.d.mts +11 -6
- package/dist/cache.d.ts +11 -6
- package/dist/cache.mjs +7 -5
- package/dist/{chunk-N6UROPT7.mjs → chunk-2FQHH5SC.mjs} +12 -13
- package/dist/{chunk-UUYF3CHN.mjs → chunk-2N5PX3LS.mjs} +2 -2
- package/dist/{chunk-H6G5INWM.cjs → chunk-2SDO73HK.cjs} +14 -156
- package/dist/{chunk-4FHDV7VM.mjs → chunk-2UABTL3Y.mjs} +2 -2
- package/dist/{chunk-LAHZ7LZA.cjs → chunk-3FCFQP5V.cjs} +32 -20
- package/dist/{chunk-3TQWUUNP.cjs → chunk-3LUF2PE2.cjs} +10 -5
- package/dist/{chunk-SYGGPS4A.mjs → chunk-4IEPYMHF.mjs} +3 -3
- package/dist/{chunk-WD5PNSOB.mjs → chunk-4V7GIE2U.mjs} +6 -4
- package/dist/{chunk-UWTQTZFN.mjs → chunk-5KDPVSS3.mjs} +271 -155
- package/dist/{chunk-I7PUUDGY.cjs → chunk-63H6BKXG.cjs} +2 -2
- package/dist/{chunk-ZSO5GWGD.cjs → chunk-6CNX6Q3K.cjs} +168 -51
- package/dist/{chunk-3PTVHMLD.mjs → chunk-6G3ZZ2IE.mjs} +1 -1
- package/dist/{chunk-QBPXNZGV.cjs → chunk-6MVFL3R5.cjs} +25 -6
- package/dist/{chunk-FG5H2VCJ.mjs → chunk-6ZCMSZ5U.mjs} +2 -2
- package/dist/{chunk-YZBV7733.cjs → chunk-74T3CEA7.cjs} +397 -281
- package/dist/{chunk-ZMN3H73H.cjs → chunk-75DYEVXI.cjs} +13 -11
- package/dist/{chunk-WIVTGKLY.mjs → chunk-7CXKSRKL.mjs} +18 -11
- package/dist/{chunk-POXI72VV.mjs → chunk-ATXI6LGT.mjs} +148 -31
- package/dist/{chunk-NL3ZSMZB.cjs → chunk-BJPBQNIE.cjs} +12 -12
- package/dist/{chunk-Q4BHBO6V.mjs → chunk-BXFWA23T.mjs} +2 -2
- package/dist/{chunk-MBFURXAC.mjs → chunk-BZ3CHOFX.mjs} +1 -1
- package/dist/{chunk-TDWFCC2T.cjs → chunk-BZAGKCKB.cjs} +2 -2
- package/dist/chunk-CNOQY6Z7.mjs +156 -0
- package/dist/{chunk-DW34V5SM.cjs → chunk-CTV2TTNP.cjs} +4 -4
- package/dist/{chunk-HG237IEY.mjs → chunk-D234YWNA.mjs} +1 -1
- package/dist/{chunk-YXM74XOW.cjs → chunk-D4JE5NNV.cjs} +12 -12
- package/dist/{chunk-O2LV5XDG.mjs → chunk-DGXN3L4D.mjs} +20 -8
- package/dist/{chunk-4UNKCNSL.mjs → chunk-E76XC6ZG.mjs} +2 -2
- package/dist/{chunk-QQQNJS2E.mjs → chunk-E7UN576T.mjs} +1 -1
- package/dist/{chunk-G3HRIVEY.cjs → chunk-ES4B2IXW.cjs} +2 -2
- package/dist/{chunk-JQGDQO2I.cjs → chunk-EXLKRR4U.cjs} +10 -10
- package/dist/chunk-FJ3M4CUX.cjs +46 -0
- package/dist/chunk-FXEF4PPL.mjs +47 -0
- package/dist/{chunk-WD4YXVLV.mjs → chunk-GZYH4OER.mjs} +1 -1
- package/dist/{chunk-DX4VKYAJ.cjs → chunk-I26CZYPV.cjs} +6 -4
- package/dist/{chunk-F6SJAKFJ.mjs → chunk-IV6CQY7O.mjs} +12 -154
- package/dist/{chunk-6D242YGO.mjs → chunk-JATSG2ZO.mjs} +1 -1
- package/dist/{chunk-KAERLFD3.cjs → chunk-JFHKNFEO.cjs} +30 -23
- package/dist/{chunk-U74A3P2P.cjs → chunk-JLRDISQL.cjs} +7 -7
- package/dist/{chunk-BYODCJD6.cjs → chunk-K7CELQLK.cjs} +12 -13
- package/dist/{chunk-Y4YWHNKU.cjs → chunk-KH7BN726.cjs} +9 -9
- package/dist/{chunk-3IL5UC5I.cjs → chunk-KZLND3D2.cjs} +2 -2
- package/dist/{chunk-TKDY6AJP.mjs → chunk-MKMBQSNQ.mjs} +1 -1
- package/dist/{chunk-OCE65DDM.mjs → chunk-MNUGPHLN.mjs} +1 -1
- package/dist/{chunk-WJKVTJJR.cjs → chunk-NPPL5YDT.cjs} +2 -2
- package/dist/{chunk-HF5SIACK.cjs → chunk-NXG66MR7.cjs} +3 -3
- package/dist/chunk-NYJMY3JA.cjs +156 -0
- package/dist/{chunk-VVJCWBIE.mjs → chunk-O3DTUAX2.mjs} +2 -2
- package/dist/{chunk-R6AIILII.cjs → chunk-OZVEHHMA.cjs} +15 -14
- package/dist/{chunk-FPW4W3VW.mjs → chunk-PQD2AI3B.mjs} +1 -1
- package/dist/{chunk-C7OUJ6JI.cjs → chunk-PZNCMPJF.cjs} +3 -3
- package/dist/{chunk-QI7WQSMI.cjs → chunk-Q5JFU33Q.cjs} +4 -4
- package/dist/{chunk-52SH7TKB.mjs → chunk-QG5HNS7P.mjs} +2 -2
- package/dist/{chunk-CEYUWDWA.mjs → chunk-QZCT2CQ4.mjs} +10 -5
- package/dist/{chunk-FZC7EEPM.mjs → chunk-RSOJ7DRT.mjs} +26 -7
- package/dist/{chunk-QMV4QELL.mjs → chunk-S5GDHOE4.mjs} +4 -2
- package/dist/{chunk-CRQPYWLK.cjs → chunk-SORB3MAR.cjs} +14 -14
- package/dist/{chunk-I4J452B7.cjs → chunk-VHJGDMCG.cjs} +3 -3
- package/dist/{chunk-B6ZCT36X.cjs → chunk-WNLBF77X.cjs} +4 -4
- package/dist/{chunk-FOT7LZEO.cjs → chunk-WPPX4G7Q.cjs} +1 -1
- package/dist/{chunk-UNSKL6BI.cjs → chunk-X4ZV4QC5.cjs} +266 -228
- package/dist/{chunk-6EG7U4NF.mjs → chunk-X7WVQMIB.mjs} +1 -1
- package/dist/chunk-XD32KALF.cjs +47 -0
- package/dist/{chunk-RDV44SED.mjs → chunk-XJJVLDM6.mjs} +15 -14
- package/dist/{chunk-DQMTHWPI.cjs → chunk-XLTV4VOG.cjs} +21 -16
- package/dist/{chunk-5SPPCN5J.mjs → chunk-XNPDONUH.mjs} +1 -1
- package/dist/{chunk-UOXGA6TO.mjs → chunk-YDQZGSDS.mjs} +1 -1
- package/dist/{chunk-JT25KHDI.mjs → chunk-YMUE7L3D.mjs} +18 -13
- package/dist/chunk-Z3HATSKO.mjs +46 -0
- package/dist/{chunk-C3VRMB6H.cjs → chunk-ZCU4NZ3M.cjs} +6 -6
- package/dist/{chunk-NPFGGBM5.cjs → chunk-ZDILFMWN.cjs} +13 -13
- package/dist/{chunk-OGHTEYXS.mjs → chunk-ZYVFAOBT.mjs} +72 -34
- package/dist/{client-plugins-1GS4zubE.d.mts → client-plugins-BX2ptm4H.d.mts} +42 -34
- package/dist/{client-plugins-B1Za6F5x.d.ts → client-plugins-BmxM5KW_.d.ts} +42 -34
- package/dist/client-plugins.d.mts +3 -2
- package/dist/client-plugins.d.ts +3 -2
- package/dist/client.cjs +11 -12
- package/dist/client.d.mts +6 -5
- package/dist/client.d.ts +6 -5
- package/dist/client.mjs +10 -11
- package/dist/config.d.mts +3 -2
- package/dist/config.d.ts +3 -2
- package/dist/{devtools-CQJ3H6MX.cjs → devtools-GGVPZHJX.cjs} +96 -21
- package/dist/{devtools-6RN6KHTW.mjs → devtools-THVNPI2M.mjs} +80 -5
- package/dist/{devtools-client-4WAPJY5L.cjs → devtools-client-CXQ6PXI6.cjs} +1 -1
- package/dist/{devtools-client-LEUIHHAS.mjs → devtools-client-HJS2T34Y.mjs} +1 -1
- package/dist/docs.cjs +9 -8
- package/dist/docs.mjs +8 -7
- package/dist/index.cjs +61 -57
- package/dist/index.d.mts +26 -15
- package/dist/index.d.ts +26 -15
- package/dist/index.mjs +69 -65
- package/dist/integrations.d.mts +3 -2
- package/dist/integrations.d.ts +3 -2
- package/dist/internal/app-markdown-runtime.cjs +5 -4
- package/dist/internal/app-markdown-runtime.d.mts +4 -3
- package/dist/internal/app-markdown-runtime.d.ts +4 -3
- package/dist/internal/app-markdown-runtime.mjs +4 -3
- package/dist/internal/build-runtime.cjs +26 -23
- package/dist/internal/build-runtime.d.mts +5 -4
- package/dist/internal/build-runtime.d.ts +5 -4
- package/dist/internal/build-runtime.mjs +25 -22
- package/dist/internal/cli-runtime.cjs +15 -13
- package/dist/internal/cli-runtime.mjs +14 -12
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +5 -1
- package/dist/internal/client-runtime.d.mts +1 -0
- package/dist/internal/client-runtime.d.ts +1 -0
- package/dist/internal/client-runtime.mjs +4 -0
- package/dist/internal/compression-runtime.cjs +3 -2
- package/dist/internal/compression-runtime.d.mts +6 -3
- package/dist/internal/compression-runtime.d.ts +6 -3
- package/dist/internal/compression-runtime.mjs +2 -1
- package/dist/internal/config-runtime.cjs +7 -6
- package/dist/internal/config-runtime.d.mts +4 -3
- package/dist/internal/config-runtime.d.ts +4 -3
- package/dist/internal/config-runtime.mjs +6 -5
- package/dist/internal/product-telemetry-runtime.cjs +10 -6
- package/dist/internal/product-telemetry-runtime.mjs +9 -5
- package/dist/internal/production-runtime.cjs +29 -13
- package/dist/internal/production-runtime.d.mts +36 -8
- package/dist/internal/production-runtime.d.ts +36 -8
- package/dist/internal/production-runtime.mjs +32 -16
- package/dist/markdown.cjs +4 -3
- package/dist/markdown.d.mts +3 -2
- package/dist/markdown.d.ts +3 -2
- package/dist/markdown.mjs +3 -2
- package/dist/{metadata-B9mCxKgp.d.mts → metadata-DsEaK7mQ.d.mts} +1 -1
- package/dist/{metadata-7LKgQEWF.d.ts → metadata-fwZ3gfG6.d.ts} +1 -1
- package/dist/middleware.cjs +6 -5
- package/dist/middleware.d.mts +4 -3
- package/dist/middleware.d.ts +4 -3
- package/dist/middleware.mjs +5 -4
- package/dist/navigation.cjs +5 -5
- package/dist/navigation.d.mts +5 -4
- package/dist/navigation.d.ts +5 -4
- package/dist/navigation.mjs +4 -4
- package/dist/plugin.cjs +25 -20
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.mjs +25 -20
- package/dist/{production-runtime-DramhI0c.d.mts → production-runtime-Baqgwtvc.d.mts} +1 -1
- package/dist/{production-runtime-B3xnY6fI.d.ts → production-runtime-DNkpFnmg.d.ts} +1 -1
- package/dist/query/client.cjs +6 -6
- package/dist/query/client.mjs +2 -2
- package/dist/{render-plan-CtQB-zHS.d.mts → render-plan-DhwQnmmX.d.mts} +1 -1
- package/dist/{render-plan-CpW32tOL.d.ts → render-plan-rkIK9wd9.d.ts} +1 -1
- package/dist/renderer-client.cjs +13 -14
- package/dist/renderer-client.d.mts +4 -3
- package/dist/renderer-client.d.ts +4 -3
- package/dist/renderer-client.mjs +6 -7
- package/dist/{request-BVGGeQv4.d.ts → request-BcY4RYPC.d.ts} +1 -1
- package/dist/{request-DlLVBKe3.d.mts → request-CFy1BltJ.d.mts} +1 -1
- package/dist/request.d.mts +4 -3
- package/dist/request.d.ts +4 -3
- package/dist/{route-rendering-DChYLNdh.d.mts → route-rendering-BkS0TBlB.d.mts} +1 -1
- package/dist/{route-rendering-BdEldajn.d.ts → route-rendering-D4XpMjam.d.ts} +1 -1
- package/dist/{router-D5htHn_M.d.mts → router-C4zPlC3V.d.mts} +1 -1
- package/dist/{router-D0Az-1Nu.d.ts → router-Cq7BcZxg.d.ts} +1 -1
- package/dist/routes.cjs +6 -5
- package/dist/routes.d.mts +3 -2
- package/dist/routes.d.ts +3 -2
- package/dist/routes.mjs +5 -4
- package/dist/server-fn-client.d.mts +1 -0
- package/dist/server-fn-client.d.ts +1 -0
- package/dist/server-fn.cjs +6 -5
- package/dist/server-fn.d.mts +1 -0
- package/dist/server-fn.d.ts +1 -0
- package/dist/server-fn.mjs +5 -4
- package/dist/server-plugins.cjs +3 -2
- package/dist/server-plugins.d.mts +3 -2
- package/dist/server-plugins.d.ts +3 -2
- package/dist/server-plugins.mjs +2 -1
- package/dist/server-query-client.cjs +5 -7
- package/dist/server-query-client.d.mts +1 -0
- package/dist/server-query-client.d.ts +1 -0
- package/dist/server-query-client.mjs +4 -6
- package/dist/server-query.cjs +7 -6
- package/dist/server-query.d.mts +1 -0
- package/dist/server-query.d.ts +1 -0
- package/dist/server-query.mjs +6 -5
- package/dist/server.cjs +72 -57
- package/dist/server.d.mts +10 -9
- package/dist/server.d.ts +10 -9
- package/dist/server.mjs +56 -41
- package/dist/{spa-router-DmwP_7QL.d.ts → spa-router-B1HI3X9k.d.ts} +2 -2
- package/dist/{spa-router-DVfSJZ5o.d.mts → spa-router-DzPZH-AO.d.mts} +2 -2
- package/dist/testing.cjs +14 -13
- package/dist/testing.d.mts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.mjs +11 -10
- package/dist/{utils-B_Rmr0-n.d.mts → utils-CEBktlBG.d.mts} +1 -1
- package/dist/{utils-Dv0OuLtF.d.ts → utils-DMD1Hzta.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +21 -19
- package/dist/vite.d.mts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.mjs +20 -18
- package/package.json +1 -1
- package/dist/{chunk-YOYF2E4U.mjs → chunk-LNZ7JZUS.mjs} +0 -0
- package/dist/{chunk-N4RLRSWW.cjs → chunk-SUIBNSNO.cjs} +0 -0
- package/dist/{chunk-TIKNUAU7.mjs → chunk-VUMAE7NC.mjs} +3 -3
- package/dist/{chunk-WM6HL7E7.cjs → chunk-ZHVYQL3H.cjs} +2 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-LPEX4YW6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/cache-key.ts
|
|
6
|
+
function createRouteDataCacheKey(key) {
|
|
7
|
+
return createFarmCacheKey(Array.isArray(key) ? key : [key]);
|
|
8
|
+
}
|
|
9
|
+
__name(createRouteDataCacheKey, "createRouteDataCacheKey");
|
|
10
|
+
function createFarmCacheKey(parts) {
|
|
11
|
+
return stableSerialize(parts);
|
|
12
|
+
}
|
|
13
|
+
__name(createFarmCacheKey, "createFarmCacheKey");
|
|
14
|
+
function getFunctionCacheIdentity(fn) {
|
|
15
|
+
const name = fn.name || "anonymous";
|
|
16
|
+
return `${name}:${hashFunctionSource(String(fn))}`;
|
|
17
|
+
}
|
|
18
|
+
__name(getFunctionCacheIdentity, "getFunctionCacheIdentity");
|
|
19
|
+
function hashFunctionSource(source) {
|
|
20
|
+
let hash = 2166136261;
|
|
21
|
+
for (let index = 0; index < source.length; index++) {
|
|
22
|
+
hash ^= source.charCodeAt(index);
|
|
23
|
+
hash = Math.imul(hash, 16777619);
|
|
24
|
+
}
|
|
25
|
+
return (hash >>> 0).toString(36);
|
|
26
|
+
}
|
|
27
|
+
__name(hashFunctionSource, "hashFunctionSource");
|
|
28
|
+
function compareCodepoint(a, b) {
|
|
29
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
30
|
+
}
|
|
31
|
+
__name(compareCodepoint, "compareCodepoint");
|
|
32
|
+
function serializeBinaryBytes(bytes) {
|
|
33
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
34
|
+
}
|
|
35
|
+
__name(serializeBinaryBytes, "serializeBinaryBytes");
|
|
36
|
+
function serializeCanonicalStringEntries(entries, seen) {
|
|
37
|
+
const valuesByKey = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const [key, item] of entries) {
|
|
39
|
+
const values = valuesByKey.get(key);
|
|
40
|
+
if (values) values.push(item);
|
|
41
|
+
else valuesByKey.set(key, [item]);
|
|
42
|
+
}
|
|
43
|
+
return Array.from(valuesByKey.keys()).sort(compareCodepoint).flatMap(
|
|
44
|
+
(key) => valuesByKey.get(key).map((item) => `[${stableSerialize(key, seen)},${stableSerialize(item, seen)}]`)
|
|
45
|
+
).join(",");
|
|
46
|
+
}
|
|
47
|
+
__name(serializeCanonicalStringEntries, "serializeCanonicalStringEntries");
|
|
48
|
+
function isPlainCacheKeyObject(value) {
|
|
49
|
+
const prototype = Object.getPrototypeOf(value);
|
|
50
|
+
if (prototype === null) return true;
|
|
51
|
+
const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
|
|
52
|
+
return Object.getPrototypeOf(prototype) === null && typeof constructor === "function" && constructor.name === "Object";
|
|
53
|
+
}
|
|
54
|
+
__name(isPlainCacheKeyObject, "isPlainCacheKeyObject");
|
|
55
|
+
function getCacheKeyValueType(value) {
|
|
56
|
+
const prototype = Object.getPrototypeOf(value);
|
|
57
|
+
const constructor = prototype ? Object.getOwnPropertyDescriptor(prototype, "constructor")?.value : void 0;
|
|
58
|
+
if (typeof constructor === "function" && constructor.name) {
|
|
59
|
+
return constructor.name;
|
|
60
|
+
}
|
|
61
|
+
return Object.prototype.toString.call(value).slice(8, -1) || "object";
|
|
62
|
+
}
|
|
63
|
+
__name(getCacheKeyValueType, "getCacheKeyValueType");
|
|
64
|
+
function stableSerialize(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
65
|
+
if (value === null) return "null";
|
|
66
|
+
if (value === void 0) return "undefined";
|
|
67
|
+
const valueType = typeof value;
|
|
68
|
+
if (valueType === "string") return JSON.stringify(value);
|
|
69
|
+
if (valueType === "number" || valueType === "boolean" || valueType === "bigint") {
|
|
70
|
+
return `${valueType}:${String(value)}`;
|
|
71
|
+
}
|
|
72
|
+
if (valueType === "symbol") {
|
|
73
|
+
return `symbol:${String(value)}`;
|
|
74
|
+
}
|
|
75
|
+
if (valueType === "function") {
|
|
76
|
+
return `function:${getFunctionCacheIdentity(value)}`;
|
|
77
|
+
}
|
|
78
|
+
if (value instanceof Date) {
|
|
79
|
+
return Number.isNaN(value.getTime()) ? "date:invalid" : `date:${value.toISOString()}`;
|
|
80
|
+
}
|
|
81
|
+
if (value instanceof URL) {
|
|
82
|
+
return `url:${value.toString()}`;
|
|
83
|
+
}
|
|
84
|
+
if (value instanceof RegExp) {
|
|
85
|
+
return `regexp:${value.toString()}`;
|
|
86
|
+
}
|
|
87
|
+
if (value instanceof ArrayBuffer) {
|
|
88
|
+
return `arraybuffer:${serializeBinaryBytes(new Uint8Array(value))}`;
|
|
89
|
+
}
|
|
90
|
+
if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer) {
|
|
91
|
+
return `sharedarraybuffer:${serializeBinaryBytes(new Uint8Array(value))}`;
|
|
92
|
+
}
|
|
93
|
+
if (ArrayBuffer.isView(value)) {
|
|
94
|
+
const viewType = Object.prototype.toString.call(value).slice(8, -1);
|
|
95
|
+
const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
96
|
+
return `binary:${viewType}:${serializeBinaryBytes(bytes)}`;
|
|
97
|
+
}
|
|
98
|
+
if (value && typeof value === "object") {
|
|
99
|
+
if (seen.has(value)) {
|
|
100
|
+
return "[Circular]";
|
|
101
|
+
}
|
|
102
|
+
seen.add(value);
|
|
103
|
+
if (Array.isArray(value)) {
|
|
104
|
+
const items = [];
|
|
105
|
+
for (let index = 0; index < value.length; index++) {
|
|
106
|
+
items.push(
|
|
107
|
+
Object.prototype.hasOwnProperty.call(value, index) ? stableSerialize(value[index], seen) : "[Hole]"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
seen.delete(value);
|
|
111
|
+
return `[${items.join(",")}]`;
|
|
112
|
+
}
|
|
113
|
+
if (value instanceof Set) {
|
|
114
|
+
const items = Array.from(value, (item) => stableSerialize(item, seen)).sort(compareCodepoint);
|
|
115
|
+
seen.delete(value);
|
|
116
|
+
return `set:[${items.join(",")}]`;
|
|
117
|
+
}
|
|
118
|
+
if (value instanceof Map) {
|
|
119
|
+
const items = Array.from(
|
|
120
|
+
value,
|
|
121
|
+
([key, item]) => `[${stableSerialize(key, seen)},${stableSerialize(item, seen)}]`
|
|
122
|
+
).sort(compareCodepoint);
|
|
123
|
+
seen.delete(value);
|
|
124
|
+
return `map:[${items.join(",")}]`;
|
|
125
|
+
}
|
|
126
|
+
if (value instanceof URLSearchParams) {
|
|
127
|
+
const serialized2 = serializeCanonicalStringEntries(value, seen);
|
|
128
|
+
seen.delete(value);
|
|
129
|
+
return `urlsearchparams:[${serialized2}]`;
|
|
130
|
+
}
|
|
131
|
+
if (value instanceof Headers) {
|
|
132
|
+
const serialized2 = serializeCanonicalStringEntries(value, seen);
|
|
133
|
+
seen.delete(value);
|
|
134
|
+
return `headers:[${serialized2}]`;
|
|
135
|
+
}
|
|
136
|
+
if (!isPlainCacheKeyObject(value)) {
|
|
137
|
+
throw new TypeError(
|
|
138
|
+
`Cache keys do not support ${getCacheKeyValueType(value)} values. Convert the value to an explicit stable string or structured key before caching.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const entries = Object.entries(value).sort(
|
|
142
|
+
([a], [b]) => compareCodepoint(a, b)
|
|
143
|
+
);
|
|
144
|
+
const serialized = entries.map(([key, item]) => `${JSON.stringify(key)}:${stableSerialize(item, seen)}`).join(",");
|
|
145
|
+
seen.delete(value);
|
|
146
|
+
return `{${serialized}}`;
|
|
147
|
+
}
|
|
148
|
+
return String(value);
|
|
149
|
+
}
|
|
150
|
+
__name(stableSerialize, "stableSerialize");
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
createRouteDataCacheKey,
|
|
154
|
+
createFarmCacheKey,
|
|
155
|
+
getFunctionCacheIdentity
|
|
156
|
+
};
|
|
@@ -26,13 +26,13 @@ var _chunkVPTDD5XFcjs = require('./chunk-VPTDD5XF.cjs');
|
|
|
26
26
|
var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkSUIBNSNOcjs = require('./chunk-SUIBNSNO.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
var _chunkIQXFRNY2cjs = require('./chunk-IQXFRNY2.cjs');
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkVHJGDMCGcjs = require('./chunk-VHJGDMCG.cjs');
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
|
|
@@ -805,7 +805,7 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
for (const route of await
|
|
808
|
+
for (const route of await _chunkSUIBNSNOcjs.discoverProgrammaticRoutePaths.call(void 0, source.root, source.srcDir)) {
|
|
809
809
|
patterns.add(route);
|
|
810
810
|
routeModulePatterns.add(route);
|
|
811
811
|
}
|
|
@@ -1201,7 +1201,7 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
1201
1201
|
const generator = new (0, _chunkXSIRSMAScjs.APITypeGenerator)(appDirs);
|
|
1202
1202
|
const apiRoutes = generator.scanAPIRoutes();
|
|
1203
1203
|
const apiTypesPath = options.apiTypesOutFile ? _path.resolve.call(void 0, root, options.apiTypesOutFile) : _path.join.call(void 0, root, srcDir, "lib", "api.generated.ts");
|
|
1204
|
-
const pluginRoutes =
|
|
1204
|
+
const pluginRoutes = _chunkVHJGDMCGcjs.resolvePluginRoutes.call(void 0, options.plugins);
|
|
1205
1205
|
const configFiles = [
|
|
1206
1206
|
...(_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.configFile).filter((file) => Boolean(file)),
|
|
1207
1207
|
options.configPath ? _path.resolve.call(void 0, root, options.configPath) : [
|
|
@@ -7,7 +7,7 @@ var _chunkD7JTOLFKcjs = require('./chunk-D7JTOLFK.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkBJPBQNIEcjs = require('./chunk-BJPBQNIE.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkLTNGXMQ6cjs = require('./chunk-LTNGXMQ6.cjs');
|
|
@@ -23,7 +23,7 @@ var _chunk5OVTOKGHcjs = require('./chunk-5OVTOKGH.cjs');
|
|
|
23
23
|
var _chunkSWN467MPcjs = require('./chunk-SWN467MP.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunk63H6BKXGcjs = require('./chunk-63H6BKXG.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var _chunkOYEUREB6cjs = require('./chunk-OYEUREB6.cjs');
|
|
@@ -147,9 +147,9 @@ function useMutationLifecycle(target, options = {}) {
|
|
|
147
147
|
};
|
|
148
148
|
});
|
|
149
149
|
const mutationTarget = targetRef.current;
|
|
150
|
-
const isAPITarget =
|
|
150
|
+
const isAPITarget = _chunkBJPBQNIEcjs.isAPIRouteRef.call(void 0, mutationTarget);
|
|
151
151
|
const sharedOptimistic = !preparationFailed && !isAPITarget ? _optionalChain([currentOptions, 'access', _3 => _3.request, 'optionalAccess', _4 => _4.optimistic]) : void 0;
|
|
152
|
-
const sharedSnapshots = _optionalChain([sharedOptimistic, 'optionalAccess', _5 => _5.update, 'optionalAccess', _6 => _6.length]) ?
|
|
152
|
+
const sharedSnapshots = _optionalChain([sharedOptimistic, 'optionalAccess', _5 => _5.update, 'optionalAccess', _6 => _6.length]) ? _chunkBJPBQNIEcjs.applyServerFnOptimisticUpdates.call(void 0, sharedOptimistic.update) : [];
|
|
153
153
|
try {
|
|
154
154
|
if (preparationFailed) throw preparationError;
|
|
155
155
|
let data;
|
|
@@ -176,9 +176,9 @@ function useMutationLifecycle(target, options = {}) {
|
|
|
176
176
|
throw cause;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
_chunkBJPBQNIEcjs.settleServerFnOptimisticUpdates.call(void 0, sharedSnapshots, "commit");
|
|
180
180
|
if (!isAPITarget && _optionalChain([currentOptions, 'access', _9 => _9.request, 'optionalAccess', _10 => _10.invalidate])) {
|
|
181
|
-
for (const key of
|
|
181
|
+
for (const key of _chunkBJPBQNIEcjs.resolveServerFnInvalidateTargets.call(void 0, currentOptions.request.invalidate)) {
|
|
182
182
|
_chunkZEG3OPIBcjs.notifyFarmCacheInvalidation.call(void 0, key);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -213,7 +213,7 @@ function useMutationLifecycle(target, options = {}) {
|
|
|
213
213
|
}
|
|
214
214
|
return data;
|
|
215
215
|
} catch (cause) {
|
|
216
|
-
|
|
216
|
+
_chunkBJPBQNIEcjs.settleServerFnOptimisticUpdates.call(void 0,
|
|
217
217
|
sharedSnapshots,
|
|
218
218
|
_optionalChain([sharedOptimistic, 'optionalAccess', _11 => _11.rollbackOnError]) ? "rollback" : "invalidate"
|
|
219
219
|
);
|
|
@@ -389,7 +389,7 @@ function useFetcher(target, options = {}) {
|
|
|
389
389
|
const Form = _react.useMemo.call(void 0, () => {
|
|
390
390
|
const FetcherForm = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, ({ action, method, encType, onSubmit, ...props }) => {
|
|
391
391
|
const targetValue = targetRef.current;
|
|
392
|
-
const metadata =
|
|
392
|
+
const metadata = _chunkBJPBQNIEcjs.getAPIRouteRefMetadata.call(void 0, targetValue);
|
|
393
393
|
const nativeAction = _nullishCoalesce(action, () => ( resolveFetcherFormAction(targetValue, metadata)));
|
|
394
394
|
const nativeMethod = _nullishCoalesce(method, () => ( (metadata && (metadata.method === "GET" || metadata.method === "POST") ? metadata.method.toLowerCase() : metadata ? "post" : void 0)));
|
|
395
395
|
const functionAction = typeof nativeAction === "function";
|
|
@@ -458,10 +458,10 @@ function mapFetcherFormData(target, formData, options) {
|
|
|
458
458
|
if (options.mapFormData) {
|
|
459
459
|
return options.mapFormData(formData, context);
|
|
460
460
|
}
|
|
461
|
-
if (!
|
|
461
|
+
if (!_chunkBJPBQNIEcjs.isAPIRouteRef.call(void 0, target)) {
|
|
462
462
|
return formData;
|
|
463
463
|
}
|
|
464
|
-
const method = _optionalChain([
|
|
464
|
+
const method = _optionalChain([_chunkBJPBQNIEcjs.getAPIRouteRefMetadata.call(void 0, target), 'optionalAccess', _14 => _14.method]);
|
|
465
465
|
const query = method === "GET" || method === "HEAD";
|
|
466
466
|
const encoding = _nullishCoalesce(_optionalChain([context, 'access', _15 => _15.submitter, 'optionalAccess', _16 => _16.getAttribute, 'call', _17 => _17("formenctype")]), () => ( _optionalChain([context, 'access', _18 => _18.form, 'optionalAccess', _19 => _19.enctype])));
|
|
467
467
|
if (!query && (_optionalChain([encoding, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()]) === "multipart/form-data" || Array.from(formData.values()).some((value) => typeof value !== "string"))) {
|
|
@@ -843,7 +843,7 @@ function initPersistedClientCache(adapter, options = {}) {
|
|
|
843
843
|
disposePersistedClientCache();
|
|
844
844
|
const engine = {
|
|
845
845
|
adapter,
|
|
846
|
-
cache:
|
|
846
|
+
cache: _chunk63H6BKXGcjs.getFarmClientDataCache.call(void 0, ),
|
|
847
847
|
version: options.version ? `${FARM_CLIENT_CACHE_PERSIST_VERSION}:${options.version}` : FARM_CLIENT_CACHE_PERSIST_VERSION,
|
|
848
848
|
persistKey: options.persistKey,
|
|
849
849
|
flushDelayMs: _nullishCoalesce(options.flushDelayMs, () => ( 300)),
|
|
@@ -896,7 +896,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, disposePersistedClientCache, "disposePersi
|
|
|
896
896
|
async function clearPersistedCache() {
|
|
897
897
|
const engine = activeEngine;
|
|
898
898
|
if (!engine) {
|
|
899
|
-
|
|
899
|
+
_chunk63H6BKXGcjs.getFarmClientDataCache.call(void 0, ).clear();
|
|
900
900
|
return;
|
|
901
901
|
}
|
|
902
902
|
engine.clearing = true;
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-IOEH4VWN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
APIRouteConflictError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BXFWA23T.mjs";
|
|
10
10
|
import {
|
|
11
11
|
findProgrammaticRouteFilesInDir
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LNZ7JZUS.mjs";
|
|
13
13
|
import {
|
|
14
14
|
isFarmAPIRouteFileName
|
|
15
15
|
} from "./chunk-CU625VAY.mjs";
|
|
@@ -18,8 +18,9 @@ import {
|
|
|
18
18
|
getAllowedAPIRouteMethods,
|
|
19
19
|
invokeAPIRouteEndpoint,
|
|
20
20
|
matchAPIRouteAtBasePath,
|
|
21
|
+
mergePluginAPIRoutes,
|
|
21
22
|
resolveAPIRouteEndpoint
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-X7WVQMIB.mjs";
|
|
23
24
|
import {
|
|
24
25
|
isProgrammaticRoutesFileName
|
|
25
26
|
} from "./chunk-EA5K5BKU.mjs";
|
|
@@ -63,6 +64,10 @@ function farmApiPlugin(options = {}) {
|
|
|
63
64
|
const basePath = options.basePath;
|
|
64
65
|
let apiRoutesCache = /* @__PURE__ */ new Map();
|
|
65
66
|
let apiRouterHandler = null;
|
|
67
|
+
let projectRoot = process.cwd();
|
|
68
|
+
let pluginMergedRoutes = null;
|
|
69
|
+
const servedRoutes = /* @__PURE__ */ __name(() => pluginMergedRoutes ?? apiRoutesCache, "servedRoutes");
|
|
70
|
+
let routePlugins;
|
|
66
71
|
let discoveryComplete = false;
|
|
67
72
|
let discoveryPromise = null;
|
|
68
73
|
let discoveryError;
|
|
@@ -179,7 +184,13 @@ function farmApiPlugin(options = {}) {
|
|
|
179
184
|
}
|
|
180
185
|
}, "restoreRouteState");
|
|
181
186
|
const createRouter = /* @__PURE__ */ __name(async () => {
|
|
182
|
-
const
|
|
187
|
+
const plugins = options.plugins ? await (routePlugins ?? (routePlugins = Promise.resolve(options.plugins({ root: projectRoot })))) : [];
|
|
188
|
+
pluginMergedRoutes = plugins.length ? new Map(
|
|
189
|
+
mergePluginAPIRoutes([...apiRoutesCache.values()], plugins, void 0, {
|
|
190
|
+
bodySizeLimit
|
|
191
|
+
}).map((route) => [route.path, route])
|
|
192
|
+
) : null;
|
|
193
|
+
const totalEndpoints = Array.from(servedRoutes().values()).reduce(
|
|
183
194
|
(sum, route) => sum + route.methods.length,
|
|
184
195
|
0
|
|
185
196
|
);
|
|
@@ -189,7 +200,7 @@ function farmApiPlugin(options = {}) {
|
|
|
189
200
|
const url = new URL(request.url);
|
|
190
201
|
const method = request.method.toUpperCase();
|
|
191
202
|
const pathname = url.pathname;
|
|
192
|
-
const match = matchAPIRouteAtBasePath(
|
|
203
|
+
const match = matchAPIRouteAtBasePath(servedRoutes(), pathname, basePath);
|
|
193
204
|
if (!match) {
|
|
194
205
|
return new Response(JSON.stringify({ error: "Not Found" }), {
|
|
195
206
|
status: 404,
|
|
@@ -223,6 +234,7 @@ function farmApiPlugin(options = {}) {
|
|
|
223
234
|
name: "@farm.js/core:api",
|
|
224
235
|
enforce: "pre",
|
|
225
236
|
configureServer(server) {
|
|
237
|
+
projectRoot = server.config.root;
|
|
226
238
|
const discoverFileRoutes = /* @__PURE__ */ __name(async (apiDir) => {
|
|
227
239
|
const fs = await import("fs");
|
|
228
240
|
const path = await import("path");
|
|
@@ -368,7 +380,7 @@ function farmApiPlugin(options = {}) {
|
|
|
368
380
|
}, "recoverFailedDiscovery");
|
|
369
381
|
server.__farmApi__ = {
|
|
370
382
|
getHandler: /* @__PURE__ */ __name(() => apiRouterHandler, "getHandler"),
|
|
371
|
-
getRoutes: /* @__PURE__ */ __name(() =>
|
|
383
|
+
getRoutes: /* @__PURE__ */ __name(() => servedRoutes(), "getRoutes"),
|
|
372
384
|
isReady: /* @__PURE__ */ __name(() => discoveryComplete, "isReady"),
|
|
373
385
|
waitForDiscovery
|
|
374
386
|
};
|
|
@@ -378,7 +390,7 @@ function farmApiPlugin(options = {}) {
|
|
|
378
390
|
const pathname = url.split("?")[0];
|
|
379
391
|
const method = req.method || "GET";
|
|
380
392
|
if (discoveryPromise) await waitForDiscovery();
|
|
381
|
-
if (!matchAPIRouteAtBasePath(
|
|
393
|
+
if (!matchAPIRouteAtBasePath(servedRoutes(), pathname, basePath)) {
|
|
382
394
|
return next();
|
|
383
395
|
}
|
|
384
396
|
if (!apiRouterHandler) {
|
|
@@ -399,7 +411,7 @@ function farmApiPlugin(options = {}) {
|
|
|
399
411
|
}
|
|
400
412
|
const currentUrl = req.url || url;
|
|
401
413
|
const currentPathname = currentUrl.split("?")[0];
|
|
402
|
-
if (currentPathname !== pathname && !matchAPIRouteAtBasePath(
|
|
414
|
+
if (currentPathname !== pathname && !matchAPIRouteAtBasePath(servedRoutes(), currentPathname, basePath)) {
|
|
403
415
|
return next();
|
|
404
416
|
}
|
|
405
417
|
const fullUrl = resolveFarmRequestURL(req);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isAPIRouteRef,
|
|
8
8
|
resolveServerFnInvalidateTargets,
|
|
9
9
|
settleServerFnOptimisticUpdates
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YDQZGSDS.mjs";
|
|
11
11
|
import {
|
|
12
12
|
notifyClientObserver
|
|
13
13
|
} from "./chunk-72AK62H5.mjs";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-5HGR3W6O.mjs";
|
|
24
24
|
import {
|
|
25
25
|
getFarmClientDataCache
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-XNPDONUH.mjs";
|
|
27
27
|
import {
|
|
28
28
|
getFarmTrailingSlashPreference
|
|
29
29
|
} from "./chunk-54UPOYFS.mjs";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
var _chunkT5CERMEHcjs = require('./chunk-T5CERMEH.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk2SDO73HKcjs = require('./chunk-2SDO73HK.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkOX6O6WVAcjs = require('./chunk-OX6O6WVA.cjs');
|
|
@@ -139,7 +139,7 @@ function createServerFn(options) {
|
|
|
139
139
|
context: resolvedContext,
|
|
140
140
|
result: parsedResult
|
|
141
141
|
}) : options.invalidates;
|
|
142
|
-
await
|
|
142
|
+
await _chunk2SDO73HKcjs.applyFarmCacheInvalidationTargets.call(void 0, declaration);
|
|
143
143
|
}
|
|
144
144
|
return parsedResult;
|
|
145
145
|
}, "run");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkSUIBNSNOcjs = require('./chunk-SUIBNSNO.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
|
|
@@ -17,7 +17,7 @@ var _chunkLYLEZIG3cjs = require('./chunk-LYLEZIG3.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkPZNCMPJFcjs = require('./chunk-PZNCMPJF.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
var _chunkWMAPPDMMcjs = require('./chunk-WMAPPDMM.cjs');
|
|
@@ -93,7 +93,7 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
93
93
|
await this.loadProgrammaticApiRoutes(appDir);
|
|
94
94
|
}
|
|
95
95
|
this.routes = new Map(
|
|
96
|
-
|
|
96
|
+
_chunkPZNCMPJFcjs.mergePluginAPIRoutes.call(void 0, [...this.routes.values()], this.plugins, void 0, {
|
|
97
97
|
bodySizeLimit: this.bodySizeLimit
|
|
98
98
|
}).map((route) => [route.path, route])
|
|
99
99
|
);
|
|
@@ -140,7 +140,7 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
140
140
|
const routeModule = await this.loadModule(filePath);
|
|
141
141
|
const endpoints = {};
|
|
142
142
|
const availableMethods = [];
|
|
143
|
-
for (const method of
|
|
143
|
+
for (const method of _chunkPZNCMPJFcjs.API_ROUTE_METHODS) {
|
|
144
144
|
if (routeModule[method]) {
|
|
145
145
|
endpoints[method] = routeModule[method];
|
|
146
146
|
availableMethods.push(method);
|
|
@@ -210,7 +210,7 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
210
210
|
async loadProgrammaticApiRoutes(appDir) {
|
|
211
211
|
const candidateRoots = [path.dirname(appDir), appDir];
|
|
212
212
|
const routeFiles = Array.from(
|
|
213
|
-
new Set(candidateRoots.flatMap((srcRoot) =>
|
|
213
|
+
new Set(candidateRoots.flatMap((srcRoot) => _chunkSUIBNSNOcjs.findProgrammaticRouteFilesInDir.call(void 0, srcRoot)))
|
|
214
214
|
);
|
|
215
215
|
if (routeFiles.length === 0) return;
|
|
216
216
|
const { getProgrammaticRouteManifest } = await import("./routes.cjs");
|
|
@@ -322,7 +322,7 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
322
322
|
const url = new URL(request.url);
|
|
323
323
|
const pathname = url.pathname;
|
|
324
324
|
const method = request.method.toUpperCase();
|
|
325
|
-
const match =
|
|
325
|
+
const match = _chunkPZNCMPJFcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
|
|
326
326
|
if (!match) {
|
|
327
327
|
return new Response(JSON.stringify({ error: "Not Found" }), {
|
|
328
328
|
status: 404,
|
|
@@ -330,19 +330,19 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
const { route, params } = match;
|
|
333
|
-
const endpoint =
|
|
333
|
+
const endpoint = _chunkPZNCMPJFcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
|
|
334
334
|
if (!endpoint) {
|
|
335
335
|
return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
|
|
336
336
|
status: 405,
|
|
337
337
|
headers: {
|
|
338
|
-
Allow:
|
|
338
|
+
Allow: _chunkPZNCMPJFcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
|
|
339
339
|
"Content-Type": "application/json"
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
const invoke = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
344
344
|
try {
|
|
345
|
-
return await
|
|
345
|
+
return await _chunkPZNCMPJFcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, this.bodySizeLimit);
|
|
346
346
|
} catch (error) {
|
|
347
347
|
if (options.throwOnError) throw error;
|
|
348
348
|
console.error(`[API Error] ${pathname}:`, error);
|
|
@@ -364,7 +364,7 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
364
364
|
return Boolean(this.matchRoute(pathname));
|
|
365
365
|
}
|
|
366
366
|
matchRoute(pathname) {
|
|
367
|
-
return
|
|
367
|
+
return _chunkPZNCMPJFcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
370
370
|
* Get all routes for client type generation
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
|
+
|
|
5
|
+
// src/owned-response.ts
|
|
6
|
+
var OWNED_RESPONSES = /* @__PURE__ */ Symbol.for("farm.ownedResponses");
|
|
7
|
+
function registry() {
|
|
8
|
+
const state = globalThis;
|
|
9
|
+
return _nullishCoalesce(state[OWNED_RESPONSES], () => ( (state[OWNED_RESPONSES] = /* @__PURE__ */ new WeakSet())));
|
|
10
|
+
}
|
|
11
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, registry, "registry");
|
|
12
|
+
function _markFarmOwnedResponse(response) {
|
|
13
|
+
registry().add(response);
|
|
14
|
+
return response;
|
|
15
|
+
}
|
|
16
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _markFarmOwnedResponse, "_markFarmOwnedResponse");
|
|
17
|
+
function _isFarmOwnedResponse(response) {
|
|
18
|
+
return registry().has(response);
|
|
19
|
+
}
|
|
20
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _isFarmOwnedResponse, "_isFarmOwnedResponse");
|
|
21
|
+
function _withFarmResponseHeaders(response, edit) {
|
|
22
|
+
if (registry().has(response)) {
|
|
23
|
+
try {
|
|
24
|
+
edit(response.headers);
|
|
25
|
+
return response;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (!(error instanceof TypeError)) throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const headers = new Headers(response.headers);
|
|
31
|
+
edit(headers);
|
|
32
|
+
return _markFarmOwnedResponse(
|
|
33
|
+
new Response(response.body, {
|
|
34
|
+
status: response.status,
|
|
35
|
+
statusText: response.statusText,
|
|
36
|
+
headers
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _withFarmResponseHeaders, "_withFarmResponseHeaders");
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports._markFarmOwnedResponse = _markFarmOwnedResponse; exports._isFarmOwnedResponse = _isFarmOwnedResponse; exports._withFarmResponseHeaders = _withFarmResponseHeaders;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-LPEX4YW6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/nitro/native-mcp-source.ts
|
|
6
|
+
function generateNativeMCPPluginSource(mcp) {
|
|
7
|
+
if (mcp?.enabled !== true) {
|
|
8
|
+
return { importSource: "", registerSource: "", pluginSource: "" };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
importSource: `import { createFarmMCPPlugin as __farmCreateMCPPlugin } from "@farm.js/mcp/internal";`,
|
|
12
|
+
registerSource: `function __farmMCPIsPlainObject(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
return prototype === Object.prototype || prototype === null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function __farmMergeMCPConfig(base, override) {
|
|
19
|
+
const output = { ...base };
|
|
20
|
+
for (const [key, value] of Object.entries(override)) {
|
|
21
|
+
if (value === undefined) continue;
|
|
22
|
+
output[key] =
|
|
23
|
+
__farmMCPIsPlainObject(output[key]) && __farmMCPIsPlainObject(value)
|
|
24
|
+
? __farmMergeMCPConfig(output[key], value)
|
|
25
|
+
: value;
|
|
26
|
+
}
|
|
27
|
+
return output;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const farmNativeMCPConfig = farmRuntimeConfigs.reduce((merged, runtimeConfig) => {
|
|
31
|
+
const value = runtimeConfig?.mcp;
|
|
32
|
+
if (value === undefined) return merged;
|
|
33
|
+
if (value === false) return false;
|
|
34
|
+
return __farmMergeMCPConfig(merged && merged !== false ? merged : {}, value);
|
|
35
|
+
}, undefined);
|
|
36
|
+
const farmNativeMCPPlugin =
|
|
37
|
+
farmNativeMCPConfig && farmNativeMCPConfig.enabled !== false
|
|
38
|
+
? __farmCreateMCPPlugin(farmNativeMCPConfig)
|
|
39
|
+
: null;`,
|
|
40
|
+
pluginSource: `...(farmNativeMCPPlugin ? [farmNativeMCPPlugin] : []),`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
__name(generateNativeMCPPluginSource, "generateNativeMCPPluginSource");
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
generateNativeMCPPluginSource
|
|
47
|
+
};
|
|
@@ -11,8 +11,10 @@ var _chunkSOR334EBcjs = require('./chunk-SOR334EB.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
var _chunk2SDO73HKcjs = require('./chunk-2SDO73HK.cjs');
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
var _chunkNYJMY3JAcjs = require('./chunk-NYJMY3JA.cjs');
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -524,10 +526,10 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
524
526
|
if (routeDataKey == null) {
|
|
525
527
|
return dataHooks.main(context);
|
|
526
528
|
}
|
|
527
|
-
const cacheKey =
|
|
529
|
+
const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeDataKey]);
|
|
528
530
|
const cacheOptions = {
|
|
529
531
|
tags: [
|
|
530
|
-
|
|
532
|
+
_chunk2SDO73HKcjs.createRouteDataCacheTag.call(void 0, routeDataKey),
|
|
531
533
|
...await resolveProgrammaticRouteDataKeys(dataHooks.tags, context)
|
|
532
534
|
],
|
|
533
535
|
paths: [
|
|
@@ -536,7 +538,7 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
536
538
|
],
|
|
537
539
|
revalidate: normalizeProgrammaticRouteStaleTime(dataHooks.staleTime)
|
|
538
540
|
};
|
|
539
|
-
return
|
|
541
|
+
return _chunk2SDO73HKcjs.getFarmDataCache.call(void 0, ).getOrSet(cacheKey, () => dataHooks.main(context), cacheOptions);
|
|
540
542
|
}
|
|
541
543
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveProgrammaticRouteData, "resolveProgrammaticRouteData");
|
|
542
544
|
async function resolveProgrammaticRouteDataKeys(input, context) {
|