@farm.js/core 0.1.0-beta.16 → 0.1.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/app-B0tE1I3o.d.ts +306 -0
- package/dist/app-Dv2JJb7X.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-AN3PQVKH.mjs → chunk-2FLBZFPG.mjs} +9 -7
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-SLDBGSC3.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-T2KL7VEL.mjs → chunk-PZXBQKCH.mjs} +13 -4
- package/dist/chunk-PZXBQKCH.mjs.map +1 -0
- package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
- package/dist/chunk-RIXKJPGI.mjs.map +1 -0
- package/dist/{chunk-OSWV5IJB.mjs → chunk-T2M5QANG.mjs} +32 -9
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-BWJC5ZOD.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-BWJC5ZOD.mjs.map → chunk-VFDBC3W7.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-278AvYHE.d.mts +2021 -0
- package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.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-E4YNCY5J.mjs → devtools-K2ERKGNI.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 +293 -58
- 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 +22 -18
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/internal/build-runtime.cjs +306 -137
- 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 +7 -7
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs +140 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +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 +44 -0
- package/dist/internal/production-runtime.d.ts +44 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-DmCudMw_.d.mts +22 -0
- package/dist/metadata-xghtOlbR.d.ts +22 -0
- package/dist/middleware.cjs +116 -98
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +5 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.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 +132 -0
- 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 +4 -4
- package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
- package/dist/production-runtime-DFN2_RXq.d.mts +79 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-Cq5d6qmE.d.mts +6 -0
- package/dist/request-LoxDW3lp.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-BA9TOSu1.d.mts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-DTAQ2HDv.d.ts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.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 +170 -3
- 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 +6 -6
- 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-B6GaYNJL.d.ts +23 -0
- package/dist/utils-CKSHiip6.d.mts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +140 -2
- 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 +4 -4
- package/dist/workflows.d.mts +110 -0
- package/dist/workflows.d.ts +110 -0
- package/package.json +1 -1
- package/types/middleware.d.ts +36 -11
- package/dist/chunk-AN3PQVKH.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-OSWV5IJB.mjs.map +0 -1
- package/dist/chunk-T2KL7VEL.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- /package/dist/{chunk-SLDBGSC3.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{devtools-E4YNCY5J.mjs.map → devtools-K2ERKGNI.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
|
@@ -3955,6 +3955,135 @@ var init_preload = __esm({
|
|
|
3955
3955
|
}
|
|
3956
3956
|
});
|
|
3957
3957
|
|
|
3958
|
+
// src/security.ts
|
|
3959
|
+
function resolveFarmSecurityConfig(input) {
|
|
3960
|
+
if (input === void 0) return { csp: false };
|
|
3961
|
+
if (!isPlainRecord(input)) {
|
|
3962
|
+
throw new TypeError("security must be an object containing the csp option.");
|
|
3963
|
+
}
|
|
3964
|
+
if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
|
|
3965
|
+
throw new TypeError(
|
|
3966
|
+
"security.contentSecurityPolicy is not supported. Use security.csp instead."
|
|
3967
|
+
);
|
|
3968
|
+
}
|
|
3969
|
+
const csp = input.csp;
|
|
3970
|
+
if (csp === void 0 || csp === false) return { csp: false };
|
|
3971
|
+
if (typeof csp === "string") {
|
|
3972
|
+
return {
|
|
3973
|
+
csp: {
|
|
3974
|
+
value: validateSerializedCsp(csp),
|
|
3975
|
+
reportOnly: false
|
|
3976
|
+
}
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
if (!isPlainRecord(csp)) {
|
|
3980
|
+
throw new TypeError("security.csp must be a policy string, false, or an options object.");
|
|
3981
|
+
}
|
|
3982
|
+
const reportOnly = validateReportOnly(csp.reportOnly);
|
|
3983
|
+
if (Object.prototype.hasOwnProperty.call(csp, "value")) {
|
|
3984
|
+
if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
|
|
3985
|
+
throw new TypeError(
|
|
3986
|
+
"Resolved security.csp values cannot include policy or directives options."
|
|
3987
|
+
);
|
|
3988
|
+
}
|
|
3989
|
+
return {
|
|
3990
|
+
csp: {
|
|
3991
|
+
value: validateSerializedCsp(csp.value),
|
|
3992
|
+
reportOnly
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
}
|
|
3996
|
+
const { policy, directives } = csp;
|
|
3997
|
+
if (policy !== void 0 && directives !== void 0) {
|
|
3998
|
+
throw new TypeError("security.csp accepts either policy or directives, not both.");
|
|
3999
|
+
}
|
|
4000
|
+
if (policy === void 0 && directives === void 0) {
|
|
4001
|
+
throw new TypeError("security.csp requires a policy string or directives object.");
|
|
4002
|
+
}
|
|
4003
|
+
return {
|
|
4004
|
+
csp: {
|
|
4005
|
+
value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
|
|
4006
|
+
reportOnly
|
|
4007
|
+
}
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
function serializeFarmCspDirectives(directives) {
|
|
4011
|
+
if (!isPlainRecord(directives)) {
|
|
4012
|
+
throw new TypeError("security.csp.directives must be an object.");
|
|
4013
|
+
}
|
|
4014
|
+
const serialized = [];
|
|
4015
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
4016
|
+
for (const [configuredName, configuredValue] of Object.entries(directives)) {
|
|
4017
|
+
if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
|
|
4018
|
+
continue;
|
|
4019
|
+
}
|
|
4020
|
+
const name = normalizeDirectiveName(configuredName);
|
|
4021
|
+
if (normalizedNames.has(name)) {
|
|
4022
|
+
throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
|
|
4023
|
+
}
|
|
4024
|
+
normalizedNames.add(name);
|
|
4025
|
+
const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
|
|
4026
|
+
validateDirectiveValue
|
|
4027
|
+
);
|
|
4028
|
+
serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
|
|
4029
|
+
}
|
|
4030
|
+
if (serialized.length === 0) {
|
|
4031
|
+
throw new TypeError("security.csp.directives must contain at least one enabled directive.");
|
|
4032
|
+
}
|
|
4033
|
+
return serialized.join("; ");
|
|
4034
|
+
}
|
|
4035
|
+
function normalizeDirectiveName(value) {
|
|
4036
|
+
const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4037
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
4038
|
+
throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
|
|
4039
|
+
}
|
|
4040
|
+
return name;
|
|
4041
|
+
}
|
|
4042
|
+
function validateDirectiveValue(value) {
|
|
4043
|
+
if (typeof value !== "string") {
|
|
4044
|
+
throw new TypeError("security.csp directive values must be strings or booleans.");
|
|
4045
|
+
}
|
|
4046
|
+
const normalized = value.trim();
|
|
4047
|
+
if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4048
|
+
throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
|
|
4049
|
+
}
|
|
4050
|
+
return normalized;
|
|
4051
|
+
}
|
|
4052
|
+
function validateSerializedCsp(value) {
|
|
4053
|
+
if (typeof value !== "string") {
|
|
4054
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4055
|
+
}
|
|
4056
|
+
const normalized = value.trim().replace(/;+$/g, "").trim();
|
|
4057
|
+
if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4058
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4059
|
+
}
|
|
4060
|
+
return normalized;
|
|
4061
|
+
}
|
|
4062
|
+
function validateReportOnly(value) {
|
|
4063
|
+
if (value === void 0) return false;
|
|
4064
|
+
if (typeof value !== "boolean") {
|
|
4065
|
+
throw new TypeError("security.csp.reportOnly must be a boolean.");
|
|
4066
|
+
}
|
|
4067
|
+
return value;
|
|
4068
|
+
}
|
|
4069
|
+
function isPlainRecord(value) {
|
|
4070
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4071
|
+
const prototype = Object.getPrototypeOf(value);
|
|
4072
|
+
return prototype === Object.prototype || prototype === null;
|
|
4073
|
+
}
|
|
4074
|
+
var init_security = __esm({
|
|
4075
|
+
"src/security.ts"() {
|
|
4076
|
+
"use strict";
|
|
4077
|
+
__name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
|
|
4078
|
+
__name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
|
|
4079
|
+
__name(normalizeDirectiveName, "normalizeDirectiveName");
|
|
4080
|
+
__name(validateDirectiveValue, "validateDirectiveValue");
|
|
4081
|
+
__name(validateSerializedCsp, "validateSerializedCsp");
|
|
4082
|
+
__name(validateReportOnly, "validateReportOnly");
|
|
4083
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
|
|
3958
4087
|
// src/write-file-if-changed.ts
|
|
3959
4088
|
function writeFileIfChanged(filePath, content) {
|
|
3960
4089
|
try {
|
|
@@ -8513,6 +8642,7 @@ var init_config2 = __esm({
|
|
|
8513
8642
|
init_config();
|
|
8514
8643
|
init_auth_config();
|
|
8515
8644
|
init_preload();
|
|
8645
|
+
init_security();
|
|
8516
8646
|
init_config_entry();
|
|
8517
8647
|
__name(getDeployTargetForPreset, "getDeployTargetForPreset");
|
|
8518
8648
|
DOCS_CONFIG_FILENAMES = [
|
|
@@ -19110,6 +19240,7 @@ init_devtools_config();
|
|
|
19110
19240
|
init_config();
|
|
19111
19241
|
init_auth_config();
|
|
19112
19242
|
init_preload();
|
|
19243
|
+
init_security();
|
|
19113
19244
|
var defaultDocsConfig = {
|
|
19114
19245
|
enabled: false,
|
|
19115
19246
|
entry: "/docs",
|
|
@@ -19177,6 +19308,7 @@ var _FarmApp = class _FarmApp {
|
|
|
19177
19308
|
routeRules: normalizeRouteRules(config.routeRules),
|
|
19178
19309
|
context: config.context || (() => void 0),
|
|
19179
19310
|
serverActions: resolveServerActionsConfig(config.serverActions),
|
|
19311
|
+
security: resolveFarmSecurityConfig(config.security),
|
|
19180
19312
|
images: resolveFarmImageConfig(config.images),
|
|
19181
19313
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
19182
19314
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|