@farm.js/core 0.1.0-beta.20 → 0.1.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/agent-runtime.mjs +1 -1
- package/dist/api/route-manager.d.mts +68 -0
- package/dist/api/route-manager.d.ts +68 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.cjs +22 -19
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +50 -0
- package/dist/api.d.ts +50 -0
- package/dist/api.mjs +2 -1
- package/dist/app-BB8GCH1g.d.ts +306 -0
- package/dist/app-DwsTpyNZ.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-MIUW47JX.mjs → chunk-2PEJGY5V.mjs} +15 -20
- package/dist/chunk-2PEJGY5V.mjs.map +1 -0
- package/dist/{chunk-RIXKJPGI.mjs → chunk-42325TLU.mjs} +2 -2
- package/dist/{chunk-UNDUIGWC.mjs → chunk-A53LP5QG.mjs} +2 -2
- package/dist/chunk-A53LP5QG.mjs.map +1 -0
- package/dist/{chunk-7BX7NEA7.mjs → chunk-CEVMYGDL.mjs} +2 -2
- package/dist/chunk-CEVMYGDL.mjs.map +1 -0
- package/dist/{chunk-ZYDQS2TT.mjs → chunk-CRN3AH35.mjs} +1 -1
- package/dist/chunk-CRN3AH35.mjs.map +1 -0
- package/dist/{chunk-4KTN2BLF.mjs → chunk-DAUR3WUZ.mjs} +2 -2
- package/dist/{chunk-4KTN2BLF.mjs.map → chunk-DAUR3WUZ.mjs.map} +1 -1
- package/dist/chunk-GIELMNBG.mjs +15 -0
- package/dist/chunk-GIELMNBG.mjs.map +1 -0
- package/dist/{chunk-4EATUJFO.mjs → chunk-ICTGDDV4.mjs} +20 -22
- package/dist/chunk-ICTGDDV4.mjs.map +1 -0
- package/dist/{chunk-5VHPEW6N.mjs → chunk-LLPN5SEZ.mjs} +2 -2
- package/dist/{chunk-TMZEK265.mjs → chunk-XBKXKJX5.mjs} +32 -37
- package/dist/chunk-XBKXKJX5.mjs.map +1 -0
- package/dist/{chunk-ZRMJY4G2.mjs → chunk-ZP73P4VR.mjs} +12 -10
- package/dist/{chunk-ZRMJY4G2.mjs.map → chunk-ZP73P4VR.mjs.map} +1 -1
- package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
- package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-CbRum1fj.d.ts +2088 -0
- package/dist/client-plugins-QQntVkrv.d.mts +2088 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/{devtools-4RDGBT72.mjs → devtools-52FYXIEK.mjs} +3 -3
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/docs.mjs +3 -3
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/font.d.mts +95 -0
- package/dist/font.d.ts +95 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/index.cjs +72 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.mjs +11 -10
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.cjs.map +1 -1
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/integrations.mjs +1 -1
- package/dist/internal/build-runtime.cjs +56 -54
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +41 -0
- package/dist/internal/build-runtime.d.ts +41 -0
- package/dist/internal/build-runtime.mjs +9 -8
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/internal/metadata-image-runtime.d.mts +25 -0
- package/dist/internal/metadata-image-runtime.d.ts +25 -0
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +66 -0
- package/dist/internal/production-runtime.d.ts +66 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-B5jBJHq1.d.ts +22 -0
- package/dist/metadata-BxOJ4FJl.d.mts +22 -0
- package/dist/middleware.cjs +17 -17
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +3 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +42 -48
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +6 -5
- package/dist/production-runtime-Bxua86uR.d.mts +81 -0
- package/dist/production-runtime-CZqXjRVi.d.ts +81 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-7V0GaZK_.d.mts +6 -0
- package/dist/request-B5XYBv5a.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-Bpp-c28k.d.ts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-Q3u74Nbq.d.mts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server.cjs +45 -67
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +11 -25
- package/dist/server.mjs.map +1 -1
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-s9pN0Yep.d.mts +23 -0
- package/dist/utils-xTFxzu47.d.ts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +44 -50
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +5 -4
- package/dist/workflows-CusFV6mn.d.mts +153 -0
- package/dist/workflows-CusFV6mn.d.ts +153 -0
- package/dist/workflows.d.mts +1 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-4EATUJFO.mjs.map +0 -1
- package/dist/chunk-7BX7NEA7.mjs.map +0 -1
- package/dist/chunk-MIUW47JX.mjs.map +0 -1
- package/dist/chunk-TMZEK265.mjs.map +0 -1
- package/dist/chunk-UNDUIGWC.mjs.map +0 -1
- package/dist/chunk-ZYDQS2TT.mjs.map +0 -1
- /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
- /package/dist/{chunk-5VHPEW6N.mjs.map → chunk-LLPN5SEZ.mjs.map} +0 -0
- /package/dist/{devtools-4RDGBT72.mjs.map → devtools-52FYXIEK.mjs.map} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
type FarmClientPluginEnforce = "pre" | "post";
|
|
3
|
+
type FarmClientNavigationAction = "push" | "replace" | "pop";
|
|
4
|
+
type FarmClientHydrationMode = "hydrate" | "render";
|
|
5
|
+
interface FarmClientLocation {
|
|
6
|
+
href: string;
|
|
7
|
+
pathname: string;
|
|
8
|
+
search: string;
|
|
9
|
+
hash: string;
|
|
10
|
+
}
|
|
11
|
+
interface FarmClientPluginRouter {
|
|
12
|
+
navigate(href: string, options?: Record<string, unknown>): MaybePromise<void>;
|
|
13
|
+
prefetch?(href: string): MaybePromise<void>;
|
|
14
|
+
getNavigationState?(): unknown;
|
|
15
|
+
}
|
|
16
|
+
interface FarmClientPluginMetadata {
|
|
17
|
+
name: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
interface FarmClientPluginSetupEvent<TPublic = undefined> {
|
|
21
|
+
plugin: FarmClientPluginMetadata;
|
|
22
|
+
public: Readonly<TPublic>;
|
|
23
|
+
router: FarmClientPluginRouter;
|
|
24
|
+
isDev: boolean;
|
|
25
|
+
isProd: boolean;
|
|
26
|
+
deploymentId?: string;
|
|
27
|
+
}
|
|
28
|
+
interface FarmClientPluginStateEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginSetupEvent<TPublic> {
|
|
29
|
+
state: TState;
|
|
30
|
+
}
|
|
31
|
+
interface FarmClientHydrationSession {
|
|
32
|
+
container: Element;
|
|
33
|
+
location: FarmClientLocation;
|
|
34
|
+
mode: FarmClientHydrationMode;
|
|
35
|
+
startedAt: number;
|
|
36
|
+
}
|
|
37
|
+
interface FarmClientHydrationEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientHydrationSession {
|
|
38
|
+
}
|
|
39
|
+
interface FarmClientHydrationCompleteEvent<TState = unknown, TPublic = undefined> extends FarmClientHydrationEvent<TState, TPublic> {
|
|
40
|
+
durationMs: number;
|
|
41
|
+
recovered: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface FarmClientNavigationSession {
|
|
44
|
+
id: string;
|
|
45
|
+
from: FarmClientLocation | null;
|
|
46
|
+
to: FarmClientLocation;
|
|
47
|
+
action: FarmClientNavigationAction;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
startedAt: number;
|
|
50
|
+
route?: {
|
|
51
|
+
pattern?: string | null;
|
|
52
|
+
params?: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface FarmClientNavigationEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientNavigationSession {
|
|
56
|
+
}
|
|
57
|
+
interface FarmClientNavigationLoadedEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationEvent<TState, TPublic> {
|
|
58
|
+
durationMs: number;
|
|
59
|
+
data?: unknown;
|
|
60
|
+
}
|
|
61
|
+
interface FarmClientNavigationResolvedEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationEvent<TState, TPublic> {
|
|
62
|
+
durationMs: number;
|
|
63
|
+
}
|
|
64
|
+
interface FarmClientNavigationErrorEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationResolvedEvent<TState, TPublic> {
|
|
65
|
+
error: unknown;
|
|
66
|
+
}
|
|
67
|
+
type FarmClientPluginErrorPhase = "setup" | "hydration" | "navigation" | "window" | "unhandled-rejection" | "performance" | `plugin:${string}` | (string & {});
|
|
68
|
+
interface FarmClientPluginErrorEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
69
|
+
error: unknown;
|
|
70
|
+
phase: FarmClientPluginErrorPhase;
|
|
71
|
+
location: FarmClientLocation;
|
|
72
|
+
navigation?: FarmClientNavigationSession;
|
|
73
|
+
}
|
|
74
|
+
interface FarmClientPerformanceEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
75
|
+
entry: PerformanceEntry;
|
|
76
|
+
location: FarmClientLocation;
|
|
77
|
+
}
|
|
78
|
+
interface FarmClientPluginCloseEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
79
|
+
reason: "pagehide" | "hmr" | "manual" | (string & {});
|
|
80
|
+
}
|
|
81
|
+
interface FarmClientPlugin<TState = unknown, TPublic = undefined> {
|
|
82
|
+
setup?(event: FarmClientPluginSetupEvent<TPublic>): MaybePromise<TState>;
|
|
83
|
+
hydration?: {
|
|
84
|
+
before?(event: FarmClientHydrationEvent<TState, TPublic>): MaybePromise<void>;
|
|
85
|
+
after?(event: FarmClientHydrationCompleteEvent<TState, TPublic>): MaybePromise<void>;
|
|
86
|
+
};
|
|
87
|
+
navigation?: {
|
|
88
|
+
before?(event: FarmClientNavigationEvent<TState, TPublic>): MaybePromise<void>;
|
|
89
|
+
loaded?(event: FarmClientNavigationLoadedEvent<TState, TPublic>): MaybePromise<void>;
|
|
90
|
+
resolved?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;
|
|
91
|
+
rendered?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;
|
|
92
|
+
error?(event: FarmClientNavigationErrorEvent<TState, TPublic>): MaybePromise<void>;
|
|
93
|
+
};
|
|
94
|
+
error?(event: FarmClientPluginErrorEvent<TState, TPublic>): MaybePromise<void>;
|
|
95
|
+
performance?(event: FarmClientPerformanceEvent<TState, TPublic>): MaybePromise<void>;
|
|
96
|
+
close?(event: FarmClientPluginCloseEvent<TState, TPublic>): MaybePromise<void>;
|
|
97
|
+
}
|
|
98
|
+
interface FarmClientPluginRegistration<TPublic = undefined> {
|
|
99
|
+
name: string;
|
|
100
|
+
version?: string;
|
|
101
|
+
enforce?: FarmClientPluginEnforce;
|
|
102
|
+
definition: FarmClientPlugin<any, TPublic>;
|
|
103
|
+
public?: TPublic;
|
|
104
|
+
}
|
|
105
|
+
interface FarmClientPluginManagerOptions {
|
|
106
|
+
router: FarmClientPluginRouter;
|
|
107
|
+
isDev?: boolean;
|
|
108
|
+
isProd?: boolean;
|
|
109
|
+
deploymentId?: string;
|
|
110
|
+
window?: Window;
|
|
111
|
+
}
|
|
112
|
+
declare class FarmClientPluginManager {
|
|
113
|
+
private readonly registrations;
|
|
114
|
+
private readonly options;
|
|
115
|
+
private readonly instances;
|
|
116
|
+
private readonly performanceObservers;
|
|
117
|
+
private startPromise?;
|
|
118
|
+
private closePromise?;
|
|
119
|
+
private currentNavigation?;
|
|
120
|
+
private navigationSequence;
|
|
121
|
+
private starting;
|
|
122
|
+
private started;
|
|
123
|
+
private closed;
|
|
124
|
+
private readonly reportedErrors;
|
|
125
|
+
private readonly handleWindowError;
|
|
126
|
+
private readonly handleUnhandledRejection;
|
|
127
|
+
private readonly handlePageHide;
|
|
128
|
+
constructor(registrations: readonly FarmClientPluginRegistration[], options: FarmClientPluginManagerOptions);
|
|
129
|
+
start(): Promise<void>;
|
|
130
|
+
beginHydration(input: {
|
|
131
|
+
container: Element;
|
|
132
|
+
mode: FarmClientHydrationMode;
|
|
133
|
+
}): Promise<FarmClientHydrationSession>;
|
|
134
|
+
completeHydration(session: FarmClientHydrationSession, options?: {
|
|
135
|
+
recovered?: boolean;
|
|
136
|
+
}): Promise<void>;
|
|
137
|
+
failHydration(session: FarmClientHydrationSession, error: unknown): Promise<void>;
|
|
138
|
+
beginNavigation(input: {
|
|
139
|
+
from?: string | URL | FarmClientLocation | null;
|
|
140
|
+
to: string | URL | FarmClientLocation;
|
|
141
|
+
action: FarmClientNavigationAction;
|
|
142
|
+
route?: FarmClientNavigationSession["route"];
|
|
143
|
+
}): Promise<FarmClientNavigationSession>;
|
|
144
|
+
markNavigationLoaded(session: FarmClientNavigationSession, data?: unknown): Promise<void>;
|
|
145
|
+
resolveNavigation(session: FarmClientNavigationSession): Promise<void>;
|
|
146
|
+
scheduleNavigationRendered(session: FarmClientNavigationSession): Promise<void>;
|
|
147
|
+
failNavigation(session: FarmClientNavigationSession, error: unknown): Promise<void>;
|
|
148
|
+
reportError(error: unknown, phase: FarmClientPluginErrorPhase, navigation?: FarmClientNavigationSession, location?: FarmClientLocation): Promise<void>;
|
|
149
|
+
close(reason?: FarmClientPluginCloseEvent["reason"]): Promise<void>;
|
|
150
|
+
getPlugins(): readonly FarmClientPluginMetadata[];
|
|
151
|
+
private startInternal;
|
|
152
|
+
private installBrowserListeners;
|
|
153
|
+
private installPerformanceObservers;
|
|
154
|
+
private closeInternal;
|
|
155
|
+
private runHook;
|
|
156
|
+
private runErrorHooks;
|
|
157
|
+
private createSetupEvent;
|
|
158
|
+
private createStateEvent;
|
|
159
|
+
private getLocation;
|
|
160
|
+
private getBaseUrl;
|
|
161
|
+
private logHookError;
|
|
162
|
+
}
|
|
163
|
+
declare function createClientPluginManager(registrations: readonly FarmClientPluginRegistration[], options: FarmClientPluginManagerOptions): FarmClientPluginManager;
|
|
164
|
+
|
|
165
|
+
export { FarmClientPluginManager as F, type FarmClientHydrationCompleteEvent as a, type FarmClientHydrationEvent as b, createClientPluginManager as c, type FarmClientHydrationMode as d, type FarmClientHydrationSession as e, type FarmClientLocation as f, type FarmClientNavigationAction as g, type FarmClientNavigationErrorEvent as h, type FarmClientNavigationEvent as i, type FarmClientNavigationLoadedEvent as j, type FarmClientNavigationResolvedEvent as k, type FarmClientNavigationSession as l, type FarmClientPerformanceEvent as m, type FarmClientPlugin as n, type FarmClientPluginCloseEvent as o, type FarmClientPluginEnforce as p, type FarmClientPluginErrorEvent as q, type FarmClientPluginErrorPhase as r, type FarmClientPluginManagerOptions as s, type FarmClientPluginMetadata as t, type FarmClientPluginRegistration as u, type FarmClientPluginRouter as v, type FarmClientPluginSetupEvent as w, type FarmClientPluginStateEvent as x };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
type FarmClientPluginEnforce = "pre" | "post";
|
|
3
|
+
type FarmClientNavigationAction = "push" | "replace" | "pop";
|
|
4
|
+
type FarmClientHydrationMode = "hydrate" | "render";
|
|
5
|
+
interface FarmClientLocation {
|
|
6
|
+
href: string;
|
|
7
|
+
pathname: string;
|
|
8
|
+
search: string;
|
|
9
|
+
hash: string;
|
|
10
|
+
}
|
|
11
|
+
interface FarmClientPluginRouter {
|
|
12
|
+
navigate(href: string, options?: Record<string, unknown>): MaybePromise<void>;
|
|
13
|
+
prefetch?(href: string): MaybePromise<void>;
|
|
14
|
+
getNavigationState?(): unknown;
|
|
15
|
+
}
|
|
16
|
+
interface FarmClientPluginMetadata {
|
|
17
|
+
name: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
interface FarmClientPluginSetupEvent<TPublic = undefined> {
|
|
21
|
+
plugin: FarmClientPluginMetadata;
|
|
22
|
+
public: Readonly<TPublic>;
|
|
23
|
+
router: FarmClientPluginRouter;
|
|
24
|
+
isDev: boolean;
|
|
25
|
+
isProd: boolean;
|
|
26
|
+
deploymentId?: string;
|
|
27
|
+
}
|
|
28
|
+
interface FarmClientPluginStateEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginSetupEvent<TPublic> {
|
|
29
|
+
state: TState;
|
|
30
|
+
}
|
|
31
|
+
interface FarmClientHydrationSession {
|
|
32
|
+
container: Element;
|
|
33
|
+
location: FarmClientLocation;
|
|
34
|
+
mode: FarmClientHydrationMode;
|
|
35
|
+
startedAt: number;
|
|
36
|
+
}
|
|
37
|
+
interface FarmClientHydrationEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientHydrationSession {
|
|
38
|
+
}
|
|
39
|
+
interface FarmClientHydrationCompleteEvent<TState = unknown, TPublic = undefined> extends FarmClientHydrationEvent<TState, TPublic> {
|
|
40
|
+
durationMs: number;
|
|
41
|
+
recovered: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface FarmClientNavigationSession {
|
|
44
|
+
id: string;
|
|
45
|
+
from: FarmClientLocation | null;
|
|
46
|
+
to: FarmClientLocation;
|
|
47
|
+
action: FarmClientNavigationAction;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
startedAt: number;
|
|
50
|
+
route?: {
|
|
51
|
+
pattern?: string | null;
|
|
52
|
+
params?: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface FarmClientNavigationEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientNavigationSession {
|
|
56
|
+
}
|
|
57
|
+
interface FarmClientNavigationLoadedEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationEvent<TState, TPublic> {
|
|
58
|
+
durationMs: number;
|
|
59
|
+
data?: unknown;
|
|
60
|
+
}
|
|
61
|
+
interface FarmClientNavigationResolvedEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationEvent<TState, TPublic> {
|
|
62
|
+
durationMs: number;
|
|
63
|
+
}
|
|
64
|
+
interface FarmClientNavigationErrorEvent<TState = unknown, TPublic = undefined> extends FarmClientNavigationResolvedEvent<TState, TPublic> {
|
|
65
|
+
error: unknown;
|
|
66
|
+
}
|
|
67
|
+
type FarmClientPluginErrorPhase = "setup" | "hydration" | "navigation" | "window" | "unhandled-rejection" | "performance" | `plugin:${string}` | (string & {});
|
|
68
|
+
interface FarmClientPluginErrorEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
69
|
+
error: unknown;
|
|
70
|
+
phase: FarmClientPluginErrorPhase;
|
|
71
|
+
location: FarmClientLocation;
|
|
72
|
+
navigation?: FarmClientNavigationSession;
|
|
73
|
+
}
|
|
74
|
+
interface FarmClientPerformanceEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
75
|
+
entry: PerformanceEntry;
|
|
76
|
+
location: FarmClientLocation;
|
|
77
|
+
}
|
|
78
|
+
interface FarmClientPluginCloseEvent<TState = unknown, TPublic = undefined> extends FarmClientPluginStateEvent<TState, TPublic> {
|
|
79
|
+
reason: "pagehide" | "hmr" | "manual" | (string & {});
|
|
80
|
+
}
|
|
81
|
+
interface FarmClientPlugin<TState = unknown, TPublic = undefined> {
|
|
82
|
+
setup?(event: FarmClientPluginSetupEvent<TPublic>): MaybePromise<TState>;
|
|
83
|
+
hydration?: {
|
|
84
|
+
before?(event: FarmClientHydrationEvent<TState, TPublic>): MaybePromise<void>;
|
|
85
|
+
after?(event: FarmClientHydrationCompleteEvent<TState, TPublic>): MaybePromise<void>;
|
|
86
|
+
};
|
|
87
|
+
navigation?: {
|
|
88
|
+
before?(event: FarmClientNavigationEvent<TState, TPublic>): MaybePromise<void>;
|
|
89
|
+
loaded?(event: FarmClientNavigationLoadedEvent<TState, TPublic>): MaybePromise<void>;
|
|
90
|
+
resolved?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;
|
|
91
|
+
rendered?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;
|
|
92
|
+
error?(event: FarmClientNavigationErrorEvent<TState, TPublic>): MaybePromise<void>;
|
|
93
|
+
};
|
|
94
|
+
error?(event: FarmClientPluginErrorEvent<TState, TPublic>): MaybePromise<void>;
|
|
95
|
+
performance?(event: FarmClientPerformanceEvent<TState, TPublic>): MaybePromise<void>;
|
|
96
|
+
close?(event: FarmClientPluginCloseEvent<TState, TPublic>): MaybePromise<void>;
|
|
97
|
+
}
|
|
98
|
+
interface FarmClientPluginRegistration<TPublic = undefined> {
|
|
99
|
+
name: string;
|
|
100
|
+
version?: string;
|
|
101
|
+
enforce?: FarmClientPluginEnforce;
|
|
102
|
+
definition: FarmClientPlugin<any, TPublic>;
|
|
103
|
+
public?: TPublic;
|
|
104
|
+
}
|
|
105
|
+
interface FarmClientPluginManagerOptions {
|
|
106
|
+
router: FarmClientPluginRouter;
|
|
107
|
+
isDev?: boolean;
|
|
108
|
+
isProd?: boolean;
|
|
109
|
+
deploymentId?: string;
|
|
110
|
+
window?: Window;
|
|
111
|
+
}
|
|
112
|
+
declare class FarmClientPluginManager {
|
|
113
|
+
private readonly registrations;
|
|
114
|
+
private readonly options;
|
|
115
|
+
private readonly instances;
|
|
116
|
+
private readonly performanceObservers;
|
|
117
|
+
private startPromise?;
|
|
118
|
+
private closePromise?;
|
|
119
|
+
private currentNavigation?;
|
|
120
|
+
private navigationSequence;
|
|
121
|
+
private starting;
|
|
122
|
+
private started;
|
|
123
|
+
private closed;
|
|
124
|
+
private readonly reportedErrors;
|
|
125
|
+
private readonly handleWindowError;
|
|
126
|
+
private readonly handleUnhandledRejection;
|
|
127
|
+
private readonly handlePageHide;
|
|
128
|
+
constructor(registrations: readonly FarmClientPluginRegistration[], options: FarmClientPluginManagerOptions);
|
|
129
|
+
start(): Promise<void>;
|
|
130
|
+
beginHydration(input: {
|
|
131
|
+
container: Element;
|
|
132
|
+
mode: FarmClientHydrationMode;
|
|
133
|
+
}): Promise<FarmClientHydrationSession>;
|
|
134
|
+
completeHydration(session: FarmClientHydrationSession, options?: {
|
|
135
|
+
recovered?: boolean;
|
|
136
|
+
}): Promise<void>;
|
|
137
|
+
failHydration(session: FarmClientHydrationSession, error: unknown): Promise<void>;
|
|
138
|
+
beginNavigation(input: {
|
|
139
|
+
from?: string | URL | FarmClientLocation | null;
|
|
140
|
+
to: string | URL | FarmClientLocation;
|
|
141
|
+
action: FarmClientNavigationAction;
|
|
142
|
+
route?: FarmClientNavigationSession["route"];
|
|
143
|
+
}): Promise<FarmClientNavigationSession>;
|
|
144
|
+
markNavigationLoaded(session: FarmClientNavigationSession, data?: unknown): Promise<void>;
|
|
145
|
+
resolveNavigation(session: FarmClientNavigationSession): Promise<void>;
|
|
146
|
+
scheduleNavigationRendered(session: FarmClientNavigationSession): Promise<void>;
|
|
147
|
+
failNavigation(session: FarmClientNavigationSession, error: unknown): Promise<void>;
|
|
148
|
+
reportError(error: unknown, phase: FarmClientPluginErrorPhase, navigation?: FarmClientNavigationSession, location?: FarmClientLocation): Promise<void>;
|
|
149
|
+
close(reason?: FarmClientPluginCloseEvent["reason"]): Promise<void>;
|
|
150
|
+
getPlugins(): readonly FarmClientPluginMetadata[];
|
|
151
|
+
private startInternal;
|
|
152
|
+
private installBrowserListeners;
|
|
153
|
+
private installPerformanceObservers;
|
|
154
|
+
private closeInternal;
|
|
155
|
+
private runHook;
|
|
156
|
+
private runErrorHooks;
|
|
157
|
+
private createSetupEvent;
|
|
158
|
+
private createStateEvent;
|
|
159
|
+
private getLocation;
|
|
160
|
+
private getBaseUrl;
|
|
161
|
+
private logHookError;
|
|
162
|
+
}
|
|
163
|
+
declare function createClientPluginManager(registrations: readonly FarmClientPluginRegistration[], options: FarmClientPluginManagerOptions): FarmClientPluginManager;
|
|
164
|
+
|
|
165
|
+
export { FarmClientPluginManager as F, type FarmClientHydrationCompleteEvent as a, type FarmClientHydrationEvent as b, createClientPluginManager as c, type FarmClientHydrationMode as d, type FarmClientHydrationSession as e, type FarmClientLocation as f, type FarmClientNavigationAction as g, type FarmClientNavigationErrorEvent as h, type FarmClientNavigationEvent as i, type FarmClientNavigationLoadedEvent as j, type FarmClientNavigationResolvedEvent as k, type FarmClientNavigationSession as l, type FarmClientPerformanceEvent as m, type FarmClientPlugin as n, type FarmClientPluginCloseEvent as o, type FarmClientPluginEnforce as p, type FarmClientPluginErrorEvent as q, type FarmClientPluginErrorPhase as r, type FarmClientPluginManagerOptions as s, type FarmClientPluginMetadata as t, type FarmClientPluginRegistration as u, type FarmClientPluginRouter as v, type FarmClientPluginSetupEvent as w, type FarmClientPluginStateEvent as x };
|
package/dist/plugin.cjs
CHANGED
|
@@ -21330,6 +21330,15 @@ __name(normalizeMiddlewareModule, "normalizeMiddlewareModule");
|
|
|
21330
21330
|
|
|
21331
21331
|
// src/middleware/manager.ts
|
|
21332
21332
|
init_response();
|
|
21333
|
+
|
|
21334
|
+
// src/cli-colors.ts
|
|
21335
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
21336
|
+
function createCliColors(interactive = process.stdout.isTTY === true) {
|
|
21337
|
+
return import_picocolors.default.createColors(interactive);
|
|
21338
|
+
}
|
|
21339
|
+
__name(createCliColors, "createCliColors");
|
|
21340
|
+
|
|
21341
|
+
// src/middleware/manager.ts
|
|
21333
21342
|
function isMiddlewareResponse(value) {
|
|
21334
21343
|
return value instanceof Response;
|
|
21335
21344
|
}
|
|
@@ -21486,23 +21495,16 @@ var _MiddlewareManager = class _MiddlewareManager {
|
|
|
21486
21495
|
if (applicable.length === 0) {
|
|
21487
21496
|
return false;
|
|
21488
21497
|
}
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
|
|
21494
|
-
|
|
21495
|
-
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
].join(" ");
|
|
21500
|
-
console.log(log);
|
|
21501
|
-
} catch {
|
|
21502
|
-
console.log(
|
|
21503
|
-
`[FARM] [MIDDLEWARE] [${method}] Executing ${pathname} (${applicable.length} middleware)`
|
|
21504
|
-
);
|
|
21505
|
-
}
|
|
21498
|
+
const pc = createCliColors();
|
|
21499
|
+
const log = [
|
|
21500
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
21501
|
+
pc.dim("[") + pc.bold(pc.magenta("MIDDLEWARE")) + pc.dim("]"),
|
|
21502
|
+
pc.dim("[") + pc.bold(pc.white(method.padEnd(3))) + pc.dim("]"),
|
|
21503
|
+
pc.gray("Executing middleware: "),
|
|
21504
|
+
pc.gray(pathname),
|
|
21505
|
+
pc.dim(` (${(Date.now() - startTime).toFixed(2)}ms)`)
|
|
21506
|
+
].join(" ");
|
|
21507
|
+
console.log(log);
|
|
21506
21508
|
for (const entry of applicable) {
|
|
21507
21509
|
const { mw, routeMatch } = entry;
|
|
21508
21510
|
const configMatch = mw.config ? this.matchesConfig(routePathname, mw.config, ctx) : { matched: true };
|
|
@@ -22874,18 +22876,14 @@ function farmPlugin(options = {}, initialPluginManager) {
|
|
|
22874
22876
|
let refreshRouteDiscovery = null;
|
|
22875
22877
|
let workflowHandler = null;
|
|
22876
22878
|
const logUpdate = /* @__PURE__ */ __name((tag, message) => {
|
|
22877
|
-
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
console.log(log);
|
|
22886
|
-
} catch {
|
|
22887
|
-
console.log(`[FARM] [${tag}] [UPDATE] ${message}`);
|
|
22888
|
-
}
|
|
22879
|
+
const pc = createCliColors();
|
|
22880
|
+
const log = [
|
|
22881
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
22882
|
+
pc.dim("[") + pc.bold(pc.cyan(tag)) + pc.dim("]"),
|
|
22883
|
+
pc.dim("[") + pc.bold(pc.yellow("UPDATE")) + pc.dim("]"),
|
|
22884
|
+
pc.gray(message)
|
|
22885
|
+
].join(" ");
|
|
22886
|
+
console.log(log);
|
|
22889
22887
|
}, "logUpdate");
|
|
22890
22888
|
return {
|
|
22891
22889
|
name: "farm",
|
|
@@ -23326,25 +23324,21 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
23326
23324
|
return;
|
|
23327
23325
|
}
|
|
23328
23326
|
logResponse.__last = { key: dedupeKey, ts: now };
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
console.log(log);
|
|
23345
|
-
} catch {
|
|
23346
|
-
console.log(`[FARM] [${tag}] [${method}] ${urlPath} - ${status} (${duration}ms)`);
|
|
23347
|
-
}
|
|
23327
|
+
const pc = createCliColors();
|
|
23328
|
+
let statusColor = pc.green;
|
|
23329
|
+
if (status >= 500) statusColor = pc.red;
|
|
23330
|
+
else if (status >= 400) statusColor = pc.yellow;
|
|
23331
|
+
else if (status >= 300) statusColor = pc.cyan;
|
|
23332
|
+
const log = [
|
|
23333
|
+
pc.dim("[") + pc.bold(pc.blue("FARM")) + pc.dim("]"),
|
|
23334
|
+
pc.dim("[") + pc.bold(pc.cyan(tag)) + pc.dim("]"),
|
|
23335
|
+
pc.dim("[") + pc.bold(pc.white(method.padEnd(3))) + pc.dim("]"),
|
|
23336
|
+
pc.gray(urlPath),
|
|
23337
|
+
pc.dim("-"),
|
|
23338
|
+
statusColor(status.toString()),
|
|
23339
|
+
pc.dim(`(${duration}ms)`)
|
|
23340
|
+
].join(" ");
|
|
23341
|
+
console.log(log);
|
|
23348
23342
|
}, "logResponse");
|
|
23349
23343
|
server.middlewares.use(
|
|
23350
23344
|
_withAfterNodeMiddleware(async (req, res, next) => {
|