@farm.js/core 0.1.15 → 0.1.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/agent-runtime.d.mts +5 -2
- package/dist/agent-runtime.d.ts +5 -2
- package/dist/api/client.cjs +62 -28
- package/dist/api/client.d.mts +3 -2
- package/dist/api/client.d.ts +3 -2
- package/dist/api/client.mjs +3 -3
- package/dist/api/route-manager.cjs +69 -32
- package/dist/api/route-manager.d.mts +5 -2
- package/dist/api/route-manager.d.ts +5 -2
- package/dist/api/route-manager.mjs +5 -5
- package/dist/api/runtime.cjs +65 -29
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/api/runtime.mjs +6 -3
- package/dist/{api-client-C8d7BZNp.d.mts → api-client-Cx54IR5g.d.mts} +2 -1
- package/dist/{api-client-BWrEbxfO.d.ts → api-client-DykpaKcY.d.ts} +2 -1
- package/dist/api.cjs +106 -33
- package/dist/api.d.mts +7 -4
- package/dist/api.d.ts +7 -4
- package/dist/api.mjs +8 -8
- package/dist/{app-wIYse61b.d.ts → app-BHY_10Lm.d.ts} +3 -3
- package/dist/{app-B3nVSjen.d.mts → app-BMk0do23.d.mts} +3 -3
- package/dist/app-markdown.d.mts +6 -3
- package/dist/app-markdown.d.ts +6 -3
- package/dist/app-markdown.mjs +3 -3
- package/dist/cache.cjs +62 -28
- package/dist/cache.d.mts +11 -1
- package/dist/cache.d.ts +11 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chunk-FOGLGRDS.mjs → chunk-4OOBRCJX.mjs} +122 -8
- package/dist/{chunk-JRF3C33L.mjs → chunk-56DAX2BE.mjs} +172 -53
- package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
- package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
- package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
- package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
- package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
- package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
- package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
- package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
- package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
- package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
- package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
- package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
- package/dist/{chunk-FBHGHMOA.mjs → chunk-MVIWBEJF.mjs} +37 -27
- package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
- package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
- package/dist/{chunk-GNTPTTLA.mjs → chunk-QGVJVSNX.mjs} +5 -5
- package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
- package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
- package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
- package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
- package/dist/{chunk-NJ47VORC.mjs → chunk-UTBVHYS3.mjs} +2 -2
- package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
- package/dist/{chunk-S3QW3BIS.mjs → chunk-WD4YXVLV.mjs} +99 -6
- package/dist/{chunk-W7IVHTOP.mjs → chunk-WD5PNSOB.mjs} +16 -3
- package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
- package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
- package/dist/{chunk-UE75PB52.mjs → chunk-YD4J4XCI.mjs} +1 -1
- package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
- package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-C089bQhN.d.ts} +16 -4
- package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-JXXmZliS.d.mts} +16 -4
- package/dist/client-plugins.d.mts +5 -2
- package/dist/client-plugins.d.ts +5 -2
- package/dist/client.cjs +62 -28
- package/dist/client.d.mts +8 -7
- package/dist/client.d.ts +8 -7
- package/dist/client.mjs +6 -6
- package/dist/config.d.mts +5 -2
- package/dist/config.d.ts +5 -2
- package/dist/cron.mjs +2 -2
- package/dist/{devtools-PCGEBRSC.mjs → devtools-UFVTMQX5.mjs} +7 -7
- package/dist/docs.cjs +83 -4
- package/dist/docs.mjs +9 -9
- package/dist/{route-CHBaW55F.d.ts → endpoint-1zA994xL.d.ts} +3 -128
- package/dist/{route-C6UClI1z.d.mts → endpoint-DAc96i93.d.mts} +3 -128
- package/dist/env.cjs +135 -8
- package/dist/env.d.mts +22 -2
- package/dist/env.d.ts +22 -2
- package/dist/env.mjs +4 -1
- package/dist/index.cjs +516 -105
- package/dist/index.d.mts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.mjs +46 -34
- package/dist/integrations.d.mts +5 -2
- package/dist/integrations.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.d.mts +5 -2
- package/dist/internal/app-markdown-runtime.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +600 -284
- package/dist/internal/build-runtime.d.mts +7 -4
- package/dist/internal/build-runtime.d.ts +7 -4
- package/dist/internal/build-runtime.mjs +23 -23
- package/dist/internal/cli-runtime.cjs +143 -33
- package/dist/internal/cli-runtime.mjs +13 -13
- package/dist/internal/client-error-overlay.cjs +1 -1
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -2
- package/dist/internal/compression-runtime.d.ts +5 -2
- package/dist/internal/config-runtime.cjs +80 -4
- package/dist/internal/config-runtime.d.mts +6 -3
- package/dist/internal/config-runtime.d.ts +6 -3
- package/dist/internal/config-runtime.mjs +7 -7
- package/dist/internal/product-telemetry-runtime.cjs +1 -1
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +101 -41
- package/dist/internal/production-runtime.d.mts +11 -8
- package/dist/internal/production-runtime.d.ts +11 -8
- package/dist/internal/production-runtime.mjs +6 -6
- package/dist/markdown.cjs +16 -1
- package/dist/markdown.mjs +1 -1
- package/dist/{metadata-BsUcOEXg.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
- package/dist/{metadata-B1bxCPUY.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
- package/dist/middleware.cjs +10 -3
- package/dist/middleware.d.mts +7 -4
- package/dist/middleware.d.ts +7 -4
- package/dist/middleware.mjs +4 -4
- package/dist/{nitro-ICBP5APY.mjs → nitro-CVZ36JM5.mjs} +8 -5
- package/dist/plugin.cjs +358 -106
- package/dist/plugin.d.mts +5 -2
- package/dist/plugin.d.ts +5 -2
- package/dist/plugin.mjs +19 -19
- package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
- package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
- package/dist/{render-plan-CNUlzylR.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
- package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
- package/dist/renderer-client.cjs +62 -28
- package/dist/renderer-client.d.mts +5 -4
- package/dist/renderer-client.d.ts +5 -4
- package/dist/renderer-client.mjs +3 -3
- package/dist/{request-Blh_f7Z3.d.mts → request-Cr53NRHr.d.mts} +1 -1
- package/dist/{request-DsVSQVfD.d.ts → request-Dt2gNuQD.d.ts} +1 -1
- package/dist/request.d.mts +6 -3
- package/dist/request.d.ts +6 -3
- package/dist/route-B0XrsrFk.d.mts +128 -0
- package/dist/route-DOEpbyWZ.d.ts +128 -0
- package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
- package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
- package/dist/routes.cjs +68 -31
- package/dist/routes.d.mts +5 -3
- package/dist/routes.d.ts +5 -3
- package/dist/routes.mjs +2 -2
- package/dist/server-fn-client.d.mts +3 -2
- package/dist/server-fn-client.d.ts +3 -2
- package/dist/server-fn.cjs +212 -32
- package/dist/server-fn.d.mts +72 -1
- package/dist/server-fn.d.ts +72 -1
- package/dist/server-fn.mjs +13 -2
- package/dist/server-plugins.d.mts +6 -3
- package/dist/server-plugins.d.ts +6 -3
- package/dist/server-query-client.cjs +62 -28
- 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 -4
- package/dist/server-query.cjs +131 -32
- package/dist/server-query.d.mts +6 -1
- package/dist/server-query.d.ts +6 -1
- package/dist/server-query.mjs +4 -3
- package/dist/server.cjs +393 -84
- package/dist/server.d.mts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.mjs +22 -22
- package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
- package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
- package/dist/testing.cjs +73 -32
- package/dist/testing.d.mts +5 -3
- package/dist/testing.d.ts +5 -3
- package/dist/testing.mjs +11 -7
- package/dist/{utils-jISOE9SD.d.ts → utils-B0XJmG_b.d.ts} +1 -1
- package/dist/{utils-DR2wfZAn.d.mts → utils-uUxF0K0P.d.mts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +500 -252
- package/dist/vite.d.mts +5 -2
- package/dist/vite.d.ts +5 -2
- package/dist/vite.mjs +19 -19
- package/dist/workflows.mjs +2 -2
- package/package.json +2 -2
- package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
- package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
- package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { E as EndpointMiddlewareResult, R as RouteSchema, a as RouteSchemaOutput, b as EndpointMCPOptions, A as AnyEndpointMiddleware, I as InferEndpointMiddlewareContext, T as TypedEndpoint, c as RouteSchemaInput } from './endpoint-1zA994xL.js';
|
|
2
|
+
|
|
3
|
+
type RouteMethod = "GET" | "HEAD" | "QUERY" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
|
4
|
+
type RoutePathParams<Path extends string> = Path extends `${infer Head}/${infer Tail}` ? RoutePathParams<Head> & RoutePathParams<Tail> : Path extends `[[...${infer Name}]]` ? {
|
|
5
|
+
[K in Name]?: string[];
|
|
6
|
+
} : Path extends `[...${infer Name}]` ? {
|
|
7
|
+
[K in Name]: string[];
|
|
8
|
+
} : Path extends `[${infer Name}]` ? {
|
|
9
|
+
[K in Name]: string;
|
|
10
|
+
} : {};
|
|
11
|
+
interface RouteInputSchemas {
|
|
12
|
+
body?: RouteSchema;
|
|
13
|
+
query?: RouteSchema;
|
|
14
|
+
params?: RouteSchema;
|
|
15
|
+
headers?: RouteSchema;
|
|
16
|
+
}
|
|
17
|
+
type Input<I, K extends PropertyKey> = K extends keyof I ? RouteSchemaInput<I[K]> : never;
|
|
18
|
+
type Output<I, K extends PropertyKey, Fallback = unknown> = K extends keyof I ? RouteSchemaOutput<I[K]> : Fallback;
|
|
19
|
+
/** JSON responses have wire types, not server-side instances such as Date. */
|
|
20
|
+
type RouteJSON<T> = T extends Response ? unknown : T extends {
|
|
21
|
+
toJSON(): infer J;
|
|
22
|
+
} ? RouteJSON<J> : T extends bigint | symbol | ((...args: any[]) => any) ? never : T extends readonly (infer V)[] ? RouteJSON<V>[] : T extends object ? {
|
|
23
|
+
[K in keyof T]: RouteJSON<T[K]>;
|
|
24
|
+
} : T;
|
|
25
|
+
type RouteDefinition<P extends string = string, M extends RouteMethod = RouteMethod, E = any> = {
|
|
26
|
+
readonly path: P;
|
|
27
|
+
readonly method: M;
|
|
28
|
+
readonly endpoint: E;
|
|
29
|
+
};
|
|
30
|
+
type RouteEndpoint<P extends string, I extends RouteInputSchemas, R> = TypedEndpoint<Output<I, "body">, Input<I, "query">, RouteJSON<R>, Input<I, "headers">, never, Input<I, "body">> & {
|
|
31
|
+
__types: {
|
|
32
|
+
params: RoutePathParams<P>;
|
|
33
|
+
inputHeaders: Input<I, "headers">;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type TrimStart<P extends string> = P extends `/${infer Rest}` ? TrimStart<Rest> : P;
|
|
37
|
+
type Join<P extends string, C extends string> = C extends "" ? P : `${P}/${TrimStart<C>}`;
|
|
38
|
+
type ParamsCheck<P extends string, I extends RouteInputSchemas> = I extends {
|
|
39
|
+
params: infer S;
|
|
40
|
+
} ? Exclude<keyof RoutePathParams<P>, keyof RouteSchemaOutput<S>> extends never ? Exclude<keyof RouteSchemaOutput<S>, keyof RoutePathParams<P>> extends never ? unknown : {
|
|
41
|
+
__error_unknown_route_params: never;
|
|
42
|
+
} : {
|
|
43
|
+
__error_missing_route_params: never;
|
|
44
|
+
} : unknown;
|
|
45
|
+
type RouteMiddlewareResults = readonly (EndpointMiddlewareResult | Promise<EndpointMiddlewareResult>)[];
|
|
46
|
+
type RouteMiddlewares<Results extends readonly unknown[]> = {
|
|
47
|
+
readonly [K in keyof Results]: (context: Parameters<AnyEndpointMiddleware>[0]) => Results[K];
|
|
48
|
+
};
|
|
49
|
+
type RouteOptions<P extends string, I extends RouteInputSchemas, O extends RouteSchema | undefined, R, MiddlewareResults extends RouteMiddlewareResults = RouteMiddlewareResults> = {
|
|
50
|
+
input?: I & ParamsCheck<P, I>;
|
|
51
|
+
/** Validate plain JSON handler results. Raw Response/stream results are never buffered. */
|
|
52
|
+
output?: O;
|
|
53
|
+
/** Opt this app-owned endpoint into an installed MCP transport. */
|
|
54
|
+
mcp?: EndpointMCPOptions;
|
|
55
|
+
middleware?: RouteMiddlewares<MiddlewareResults>;
|
|
56
|
+
handler(request: Request, context: {
|
|
57
|
+
input: {
|
|
58
|
+
body: Output<I, "body">;
|
|
59
|
+
query: Output<I, "query", Record<string, string | string[]>>;
|
|
60
|
+
headers: Output<I, "headers", Record<string, string>>;
|
|
61
|
+
params: Output<I, "params", RoutePathParams<P>>;
|
|
62
|
+
};
|
|
63
|
+
params: Output<I, "params", RoutePathParams<P>>;
|
|
64
|
+
context: Readonly<InferEndpointMiddlewareContext<RouteMiddlewares<MiddlewareResults>>>;
|
|
65
|
+
}): R | Promise<R>;
|
|
66
|
+
};
|
|
67
|
+
type RouteBuilder<P extends string, M extends RouteMethod> = <const C extends string, const MiddlewareResults extends RouteMiddlewareResults, const I extends RouteInputSchemas = {}, O extends RouteSchema | undefined = undefined, R = unknown>(path: C, options: RouteOptions<Join<P, C>, I, O, R, MiddlewareResults>) => RouteDefinition<Join<P, C>, M, RouteEndpoint<Join<P, C>, I, Extract<Awaited<R>, Response> extends never ? O extends RouteSchema ? RouteSchemaOutput<O> : Awaited<R> : unknown>>;
|
|
68
|
+
type RouteFactory<P extends string = ""> = {
|
|
69
|
+
[M in Lowercase<RouteMethod>]: RouteBuilder<P, Uppercase<M> & RouteMethod>;
|
|
70
|
+
} & {
|
|
71
|
+
/** Return a new builder; never mutate the parent scope. */
|
|
72
|
+
scope<const C extends string>(path: C): RouteFactory<Join<P, C>>;
|
|
73
|
+
};
|
|
74
|
+
type PluginRoutes = readonly RouteDefinition[];
|
|
75
|
+
interface PluginLocalAPIEndpoint {
|
|
76
|
+
readonly path: string;
|
|
77
|
+
readonly method: RouteMethod;
|
|
78
|
+
readonly input: Readonly<RouteInputSchemas>;
|
|
79
|
+
readonly output?: RouteSchema;
|
|
80
|
+
readonly mcp?: EndpointMCPOptions;
|
|
81
|
+
invoke(request: Request, params?: Readonly<Record<string, string | string[]>>): Promise<Response>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Read-only access to app-owned API endpoints while plugin routes are mounted.
|
|
85
|
+
* Plugin routes are intentionally excluded so a plugin cannot recurse through
|
|
86
|
+
* itself or depend on plugin registration order.
|
|
87
|
+
*/
|
|
88
|
+
interface PluginLocalAPI {
|
|
89
|
+
/** False during type-only route discovery, where app endpoint modules are unavailable. */
|
|
90
|
+
readonly available: boolean;
|
|
91
|
+
get(method: RouteMethod, path: string): PluginLocalAPIEndpoint | undefined;
|
|
92
|
+
/** Enumerate app-owned endpoints. Plugin routes are excluded. */
|
|
93
|
+
list(): readonly PluginLocalAPIEndpoint[];
|
|
94
|
+
}
|
|
95
|
+
type PluginRoutesFactory<R extends PluginRoutes = PluginRoutes> = (context: {
|
|
96
|
+
route: RouteFactory;
|
|
97
|
+
api: PluginLocalAPI;
|
|
98
|
+
}) => R;
|
|
99
|
+
declare function createRouteFactory(): RouteFactory;
|
|
100
|
+
type UnionToIntersection<U> = (U extends unknown ? (v: U) => void : never) extends (v: infer I) => void ? I : never;
|
|
101
|
+
type RouteTree<P extends string, M extends string, E> = P extends `${infer Head}/${infer Tail}` ? {
|
|
102
|
+
[K in Head]: RouteTree<Tail, M, E>;
|
|
103
|
+
} : P extends "" ? {
|
|
104
|
+
[K in Lowercase<M>]: E;
|
|
105
|
+
} : {
|
|
106
|
+
[K in P]: {
|
|
107
|
+
[Method in Lowercase<M>]: E;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
type HasMethodSegment<P extends string> = P extends `${infer H}/${infer T}` ? H extends Lowercase<RouteMethod> ? true : HasMethodSegment<T> : P extends Lowercase<RouteMethod> ? true : false;
|
|
111
|
+
type DefinitionTree<D> = D extends RouteDefinition<infer P, infer M, infer E> ? string extends P ? {} : (P extends `/api/integrations${string}` ? true : HasMethodSegment<P>) extends true ? {
|
|
112
|
+
[K in P extends `/api/${infer C}` ? `/${C}` : "/"]: {
|
|
113
|
+
[Method in Lowercase<M>]: E;
|
|
114
|
+
};
|
|
115
|
+
} : RouteTree<P extends `/api/${infer C}` ? C : "", M, E> : {};
|
|
116
|
+
type PluginAPIRouter<C> = C extends {
|
|
117
|
+
plugins: readonly (infer P)[];
|
|
118
|
+
} ? UnionToIntersection<P extends {
|
|
119
|
+
routes?: PluginRoutesFactory<infer R>;
|
|
120
|
+
} ? DefinitionTree<R[number]> : {}> : {};
|
|
121
|
+
declare function resolvePluginRoutes(plugins?: readonly {
|
|
122
|
+
name: string;
|
|
123
|
+
routes?: PluginRoutesFactory;
|
|
124
|
+
}[], context?: {
|
|
125
|
+
api?: PluginLocalAPI;
|
|
126
|
+
}): PluginRoutes;
|
|
127
|
+
|
|
128
|
+
export { type PluginRoutesFactory as P, type RouteMethod as R, type RoutePathParams as a, type RouteInputSchemas as b, type RouteJSON as c, type RouteDefinition as d, type RouteOptions as e, type RouteFactory as f, type PluginRoutes as g, type PluginLocalAPIEndpoint as h, type PluginLocalAPI as i, createRouteFactory as j, type PluginAPIRouter as k, resolvePluginRoutes as r };
|
package/dist/routes.cjs
CHANGED
|
@@ -428,6 +428,8 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
428
428
|
constructor(config = {}) {
|
|
429
429
|
this.entries = /* @__PURE__ */ new Map();
|
|
430
430
|
this.inflight = /* @__PURE__ */ new Map();
|
|
431
|
+
/** Local entries by tag, so tag counts and pruning never scan unrelated entries. */
|
|
432
|
+
this.entriesByTag = /* @__PURE__ */ new Map();
|
|
431
433
|
this.invalidatedTagVersions = /* @__PURE__ */ new Map();
|
|
432
434
|
this.activeGenerations = /* @__PURE__ */ new Set();
|
|
433
435
|
this.version = 0;
|
|
@@ -446,6 +448,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
446
448
|
configure(config = {}) {
|
|
447
449
|
this.generation++;
|
|
448
450
|
this.entries.clear();
|
|
451
|
+
this.entriesByTag.clear();
|
|
449
452
|
this.inflight.clear();
|
|
450
453
|
this.invalidatedTagVersions.clear();
|
|
451
454
|
this.activeGenerations.clear();
|
|
@@ -612,14 +615,12 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
612
615
|
return entry;
|
|
613
616
|
}
|
|
614
617
|
delete(key) {
|
|
615
|
-
const deleted = this.
|
|
616
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
618
|
+
const deleted = this.deleteLocalEntry(key);
|
|
617
619
|
emitFarmEvent({ type: "cache.delete", key, deleted });
|
|
618
620
|
return deleted;
|
|
619
621
|
}
|
|
620
622
|
async deleteAsync(key) {
|
|
621
|
-
const deleted = this.
|
|
622
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
623
|
+
const deleted = this.deleteLocalEntry(key);
|
|
623
624
|
if (this.adapter) {
|
|
624
625
|
await this.adapter.delete(this.createAdapterKey(key));
|
|
625
626
|
}
|
|
@@ -630,6 +631,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
630
631
|
const count = this.entries.size;
|
|
631
632
|
this.generation++;
|
|
632
633
|
this.entries.clear();
|
|
634
|
+
this.entriesByTag.clear();
|
|
633
635
|
this.inflight.clear();
|
|
634
636
|
this.invalidatedTagVersions.clear();
|
|
635
637
|
this.activeGenerations.clear();
|
|
@@ -715,23 +717,32 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
715
717
|
return cached.value;
|
|
716
718
|
}
|
|
717
719
|
const inflight = this.inflight.get(key);
|
|
718
|
-
if (inflight) {
|
|
720
|
+
if (inflight && !this.wasInvalidatedSince(inflight.tags, inflight.startVersion)) {
|
|
719
721
|
emitFarmEvent({ type: "cache.dedupe", key });
|
|
720
|
-
return inflight;
|
|
722
|
+
return inflight.promise;
|
|
721
723
|
}
|
|
722
724
|
const tags = Array.from(normalizeCacheOptionsTags(options));
|
|
723
725
|
const generation = this.generation;
|
|
726
|
+
const startVersion = this.version;
|
|
724
727
|
const promise = this.fillCacheEntry(key, producer, options, tags, generation).catch((error) => {
|
|
725
728
|
emitFarmEvent({ type: "cache.error", key, operation: "set", error });
|
|
726
729
|
throw error;
|
|
727
730
|
}).finally(() => {
|
|
728
|
-
if (this.inflight.get(key) === promise) {
|
|
731
|
+
if (this.inflight.get(key)?.promise === promise) {
|
|
729
732
|
this.inflight.delete(key);
|
|
730
733
|
}
|
|
731
734
|
});
|
|
732
|
-
this.inflight.set(key, promise);
|
|
735
|
+
this.inflight.set(key, { promise, tags, startVersion });
|
|
733
736
|
return promise;
|
|
734
737
|
}
|
|
738
|
+
/** A fill that started before one of its tags was invalidated cannot satisfy later readers. */
|
|
739
|
+
wasInvalidatedSince(tags, version) {
|
|
740
|
+
for (const tag of tags) {
|
|
741
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
742
|
+
if (invalidatedVersion !== void 0 && invalidatedVersion > version) return true;
|
|
743
|
+
}
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
735
746
|
async fillCacheEntry(key, producer, options, tags, generation) {
|
|
736
747
|
const adapter = this.adapter;
|
|
737
748
|
const namespace = this.namespace;
|
|
@@ -772,7 +783,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
772
783
|
return value;
|
|
773
784
|
} finally {
|
|
774
785
|
this.activeGenerations.delete(activeGeneration);
|
|
775
|
-
this.pruneInvalidatedTagVersions();
|
|
786
|
+
this.pruneInvalidatedTagVersions(activeGeneration.tags);
|
|
776
787
|
if (leaseToken && adapter?.releaseLease) {
|
|
777
788
|
try {
|
|
778
789
|
await adapter.releaseLease(leaseKey, leaseToken);
|
|
@@ -817,18 +828,9 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
817
828
|
}
|
|
818
829
|
return void 0;
|
|
819
830
|
}
|
|
820
|
-
countEntriesForTag(tag) {
|
|
821
|
-
let count = 0;
|
|
822
|
-
for (const entry of this.entries.values()) {
|
|
823
|
-
if (entry.tags.has(tag)) {
|
|
824
|
-
count++;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
return count;
|
|
828
|
-
}
|
|
829
831
|
countEntriesForTags(tags) {
|
|
830
832
|
let count = 0;
|
|
831
|
-
for (const entry of this.
|
|
833
|
+
for (const entry of this.entriesByTag.get(tags[0]) ?? []) {
|
|
832
834
|
if (tags.every((tag) => entry.tags.has(tag))) {
|
|
833
835
|
count++;
|
|
834
836
|
}
|
|
@@ -836,10 +838,10 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
836
838
|
return count;
|
|
837
839
|
}
|
|
838
840
|
invalidateTag(normalizedTag) {
|
|
839
|
-
const count = this.
|
|
841
|
+
const count = this.entriesByTag.get(normalizedTag)?.size ?? 0;
|
|
840
842
|
this.invalidatedTagVersions.delete(normalizedTag);
|
|
841
843
|
this.invalidatedTagVersions.set(normalizedTag, ++this.version);
|
|
842
|
-
this.pruneInvalidatedTagVersions();
|
|
844
|
+
this.pruneInvalidatedTagVersions([normalizedTag]);
|
|
843
845
|
return count;
|
|
844
846
|
}
|
|
845
847
|
toPublicEntry(entry) {
|
|
@@ -869,19 +871,51 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
869
871
|
this.entries.set(key, entry);
|
|
870
872
|
}
|
|
871
873
|
storeLocalEntry(entry) {
|
|
872
|
-
|
|
874
|
+
const removed = [];
|
|
875
|
+
const replaced = this.detachLocalEntry(entry.key);
|
|
876
|
+
if (replaced) removed.push(replaced);
|
|
873
877
|
this.entries.set(entry.key, entry);
|
|
878
|
+
for (const tag of entry.tags) {
|
|
879
|
+
let tagged = this.entriesByTag.get(tag);
|
|
880
|
+
if (!tagged) this.entriesByTag.set(tag, tagged = /* @__PURE__ */ new Set());
|
|
881
|
+
tagged.add(entry);
|
|
882
|
+
}
|
|
874
883
|
while (this.entries.size > this.maxEntries) {
|
|
875
884
|
const oldestKey = this.entries.keys().next().value;
|
|
876
885
|
if (oldestKey === void 0) break;
|
|
877
|
-
this.
|
|
886
|
+
removed.push(this.detachLocalEntry(oldestKey));
|
|
878
887
|
}
|
|
879
|
-
this.pruneInvalidatedTagVersions();
|
|
888
|
+
for (const removedEntry of removed) this.pruneInvalidatedTagVersions(removedEntry.tags);
|
|
889
|
+
}
|
|
890
|
+
deleteLocalEntry(key) {
|
|
891
|
+
const entry = this.detachLocalEntry(key);
|
|
892
|
+
if (!entry) return false;
|
|
893
|
+
this.pruneInvalidatedTagVersions(entry.tags);
|
|
894
|
+
return true;
|
|
880
895
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
896
|
+
detachLocalEntry(key) {
|
|
897
|
+
const entry = this.entries.get(key);
|
|
898
|
+
if (!entry) return void 0;
|
|
899
|
+
this.entries.delete(key);
|
|
900
|
+
for (const tag of entry.tags) {
|
|
901
|
+
const tagged = this.entriesByTag.get(tag);
|
|
902
|
+
if (!tagged) continue;
|
|
903
|
+
tagged.delete(entry);
|
|
904
|
+
if (tagged.size === 0) this.entriesByTag.delete(tag);
|
|
905
|
+
}
|
|
906
|
+
return entry;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Drop invalidation versions that no local entry or active fill can be stale against.
|
|
910
|
+
* Callers pass only the tags whose dependents just changed, so the cost is bounded by
|
|
911
|
+
* the entries sharing those tags rather than by the whole cache.
|
|
912
|
+
*/
|
|
913
|
+
pruneInvalidatedTagVersions(tags) {
|
|
914
|
+
tags: for (const tag of tags) {
|
|
915
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
916
|
+
if (invalidatedVersion === void 0) continue;
|
|
917
|
+
for (const entry of this.entriesByTag.get(tag) ?? []) {
|
|
918
|
+
if (entry.createdVersion < invalidatedVersion) continue tags;
|
|
885
919
|
}
|
|
886
920
|
for (const generation of this.activeGenerations) {
|
|
887
921
|
if (generation.tags.has(tag) && generation.createdVersion < invalidatedVersion)
|
|
@@ -2066,6 +2100,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
|
|
|
2066
2100
|
}
|
|
2067
2101
|
return rendererRuntime.createElement(...args);
|
|
2068
2102
|
}, "createElement");
|
|
2103
|
+
const markFunctionComponent = /* @__PURE__ */ __name((component) => rendererRuntime?.markFunctionComponent?.(component) ?? component, "markFunctionComponent");
|
|
2069
2104
|
const Component = route.component;
|
|
2070
2105
|
if (route.pending) {
|
|
2071
2106
|
const PendingComponent = route.pending;
|
|
@@ -2087,7 +2122,9 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
|
|
|
2087
2122
|
throw error;
|
|
2088
2123
|
}
|
|
2089
2124
|
}, "FarmProgrammaticPageContent");
|
|
2090
|
-
const PageContent =
|
|
2125
|
+
const PageContent = markFunctionComponent(
|
|
2126
|
+
FarmProgrammaticPageContent2
|
|
2127
|
+
);
|
|
2091
2128
|
const FarmProgrammaticPage = /* @__PURE__ */ __name(function FarmProgrammaticPage2(props) {
|
|
2092
2129
|
return createElement(
|
|
2093
2130
|
rendererRuntime.Suspense,
|
|
@@ -2097,7 +2134,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
|
|
|
2097
2134
|
createElement(PageContent, props)
|
|
2098
2135
|
);
|
|
2099
2136
|
}, "FarmProgrammaticPage");
|
|
2100
|
-
return FarmProgrammaticPage;
|
|
2137
|
+
return markFunctionComponent(FarmProgrammaticPage);
|
|
2101
2138
|
}
|
|
2102
2139
|
const FarmProgrammaticPageContent = /* @__PURE__ */ __name(async function FarmProgrammaticPageContent2(props) {
|
|
2103
2140
|
try {
|
|
@@ -2116,7 +2153,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
|
|
|
2116
2153
|
throw error;
|
|
2117
2154
|
}
|
|
2118
2155
|
}, "FarmProgrammaticPageContent");
|
|
2119
|
-
return FarmProgrammaticPageContent;
|
|
2156
|
+
return markFunctionComponent(FarmProgrammaticPageContent);
|
|
2120
2157
|
}
|
|
2121
2158
|
__name(createProgrammaticPageComponent, "createProgrammaticPageComponent");
|
|
2122
2159
|
function readProgrammaticRouteProps(route, props, resources) {
|
package/dist/routes.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { F as FarmRouteRuntimeConfig, L as LayoutProps, M as Metadata, e as FarmRouteRuntime, f as FarmRouteRegions, g as FarmRouteMaxDuration, h as FarmAppContext, i as PageProps, j as PluginContextProps, k as RouteModule, P as ParsedRoute } from './client-plugins-
|
|
1
|
+
import { F as FarmRouteRuntimeConfig, L as LayoutProps, M as Metadata, e as FarmRouteRuntime, f as FarmRouteRegions, g as FarmRouteMaxDuration, h as FarmAppContext, i as PageProps, j as PluginContextProps, k as RouteModule, P as ParsedRoute } from './client-plugins-JXXmZliS.mjs';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
import { RouteDataCacheKey } from './cache.mjs';
|
|
4
4
|
import { ServerFn } from './server-fn.mjs';
|
|
5
5
|
import { FarmServerRendererRuntime } from './renderer.mjs';
|
|
6
6
|
import './lifecycle-DK06VuKP.mjs';
|
|
7
|
-
import './route-
|
|
7
|
+
import './route-B0XrsrFk.mjs';
|
|
8
|
+
import './endpoint-DAc96i93.mjs';
|
|
8
9
|
import 'http';
|
|
9
10
|
import './markdown.mjs';
|
|
10
11
|
import './types-Cc8l9IqS.mjs';
|
|
@@ -27,6 +28,7 @@ import './server-fn-error-DDh14a0V.mjs';
|
|
|
27
28
|
import 'esbuild';
|
|
28
29
|
import './image-config-Duob7wER.mjs';
|
|
29
30
|
import './types-Z0aotQ8w.mjs';
|
|
31
|
+
import './server-query.mjs';
|
|
30
32
|
import './types-DQnyD3VD.mjs';
|
|
31
33
|
import './font.mjs';
|
|
32
34
|
import './after.mjs';
|
|
@@ -259,7 +261,7 @@ declare function parseProgrammaticRouteModuleId(moduleId: string): {
|
|
|
259
261
|
routePath: string;
|
|
260
262
|
} | null;
|
|
261
263
|
declare function parseProgrammaticRoutePath(routePath: string, type?: ParsedRoute["type"]): ParsedRoute;
|
|
262
|
-
declare function createRouteModuleFromProgrammaticPage(route: ProgrammaticPageRoute, rendererRuntime?: Pick<FarmServerRendererRuntime, "createElement" | "Suspense">): RouteModule;
|
|
264
|
+
declare function createRouteModuleFromProgrammaticPage(route: ProgrammaticPageRoute, rendererRuntime?: Pick<FarmServerRendererRuntime, "createElement" | "Suspense" | "markFunctionComponent">): RouteModule;
|
|
263
265
|
declare function createLayoutModuleFromProgrammaticLayout(route: ProgrammaticLayoutRoute): {
|
|
264
266
|
metadata: (Metadata & Record<string, any>) | undefined;
|
|
265
267
|
generateMetadata: ((props: {
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { F as FarmRouteRuntimeConfig, L as LayoutProps, M as Metadata, e as FarmRouteRuntime, f as FarmRouteRegions, g as FarmRouteMaxDuration, h as FarmAppContext, i as PageProps, j as PluginContextProps, k as RouteModule, P as ParsedRoute } from './client-plugins-
|
|
1
|
+
import { F as FarmRouteRuntimeConfig, L as LayoutProps, M as Metadata, e as FarmRouteRuntime, f as FarmRouteRegions, g as FarmRouteMaxDuration, h as FarmAppContext, i as PageProps, j as PluginContextProps, k as RouteModule, P as ParsedRoute } from './client-plugins-C089bQhN.js';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
import { RouteDataCacheKey } from './cache.js';
|
|
4
4
|
import { ServerFn } from './server-fn.js';
|
|
5
5
|
import { FarmServerRendererRuntime } from './renderer.js';
|
|
6
6
|
import './lifecycle-DK06VuKP.js';
|
|
7
|
-
import './route-
|
|
7
|
+
import './route-DOEpbyWZ.js';
|
|
8
|
+
import './endpoint-1zA994xL.js';
|
|
8
9
|
import 'http';
|
|
9
10
|
import './markdown.js';
|
|
10
11
|
import './types-Cc8l9IqS.js';
|
|
@@ -27,6 +28,7 @@ import './server-fn-error-DDh14a0V.js';
|
|
|
27
28
|
import 'esbuild';
|
|
28
29
|
import './image-config-Duob7wER.js';
|
|
29
30
|
import './types-Z0aotQ8w.js';
|
|
31
|
+
import './server-query.js';
|
|
30
32
|
import './types-DQnyD3VD.js';
|
|
31
33
|
import './font.js';
|
|
32
34
|
import './after.js';
|
|
@@ -259,7 +261,7 @@ declare function parseProgrammaticRouteModuleId(moduleId: string): {
|
|
|
259
261
|
routePath: string;
|
|
260
262
|
} | null;
|
|
261
263
|
declare function parseProgrammaticRoutePath(routePath: string, type?: ParsedRoute["type"]): ParsedRoute;
|
|
262
|
-
declare function createRouteModuleFromProgrammaticPage(route: ProgrammaticPageRoute, rendererRuntime?: Pick<FarmServerRendererRuntime, "createElement" | "Suspense">): RouteModule;
|
|
264
|
+
declare function createRouteModuleFromProgrammaticPage(route: ProgrammaticPageRoute, rendererRuntime?: Pick<FarmServerRendererRuntime, "createElement" | "Suspense" | "markFunctionComponent">): RouteModule;
|
|
263
265
|
declare function createLayoutModuleFromProgrammaticLayout(route: ProgrammaticLayoutRoute): {
|
|
264
266
|
metadata: (Metadata & Record<string, any>) | undefined;
|
|
265
267
|
generateMetadata: ((props: {
|
package/dist/routes.mjs
CHANGED
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
redirect,
|
|
20
20
|
routesBuilder,
|
|
21
21
|
scanProgrammaticPagePaths
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-TSWW5BVH.mjs";
|
|
23
23
|
import "./chunk-SEJ5N6SL.mjs";
|
|
24
24
|
import "./chunk-EA5K5BKU.mjs";
|
|
25
25
|
import "./chunk-FS7FLPOG.mjs";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-F6SJAKFJ.mjs";
|
|
27
27
|
import "./chunk-4SIYUGRY.mjs";
|
|
28
28
|
import "./chunk-C4NCTZLM.mjs";
|
|
29
29
|
import "./chunk-FUZEBRP3.mjs";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FormHTMLAttributes, ComponentType } from 'react';
|
|
2
2
|
import { ServerFn } from './server-fn.mjs';
|
|
3
|
-
import { R as RetryOptions } from './api-client-
|
|
3
|
+
import { R as RetryOptions } from './api-client-Cx54IR5g.mjs';
|
|
4
4
|
import './cache.mjs';
|
|
5
5
|
import './server-fn-error-DDh14a0V.mjs';
|
|
6
|
+
import './endpoint-DAc96i93.mjs';
|
|
6
7
|
import './integration-api-BbaiokCC.mjs';
|
|
7
8
|
import './client-cache-di_Nasxa.mjs';
|
|
8
|
-
import './route-
|
|
9
|
+
import './route-B0XrsrFk.mjs';
|
|
9
10
|
|
|
10
11
|
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
11
12
|
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FormHTMLAttributes, ComponentType } from 'react';
|
|
2
2
|
import { ServerFn } from './server-fn.js';
|
|
3
|
-
import { R as RetryOptions } from './api-client-
|
|
3
|
+
import { R as RetryOptions } from './api-client-DykpaKcY.js';
|
|
4
4
|
import './cache.js';
|
|
5
5
|
import './server-fn-error-DDh14a0V.js';
|
|
6
|
+
import './endpoint-1zA994xL.js';
|
|
6
7
|
import './integration-api-BbaiokCC.js';
|
|
7
8
|
import './client-cache-Deoqq-nM.js';
|
|
8
|
-
import './route-
|
|
9
|
+
import './route-DOEpbyWZ.js';
|
|
9
10
|
|
|
10
11
|
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
|
|
11
12
|
type ServerFnSubmit<TInput, TResult> = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise<TResult> : (input: TInput | FormData) => Promise<TResult>;
|