@pracht/core 0.6.1 → 0.8.0
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/app-BWriseLj.d.mts +298 -0
- package/dist/app-BvC1uQG5.mjs +308 -0
- package/dist/browser.d.mts +7 -0
- package/dist/browser.mjs +8 -0
- package/dist/client.d.mts +4 -0
- package/dist/client.mjs +4 -0
- package/dist/forwardRef-grZ6t4GS.mjs +27 -0
- package/dist/hydration-M1QzbQ1O.d.mts +23 -0
- package/dist/index.d.mts +7 -438
- package/dist/index.mjs +7 -1965
- package/dist/manifest.d.mts +2 -0
- package/dist/manifest.mjs +2 -0
- package/dist/prefetch-B50kX9RL.mjs +118 -0
- package/dist/prefetch-cache-DzP2Bj9H.mjs +129 -0
- package/dist/prerender-B8_CqYwd.d.mts +51 -0
- package/dist/prerender-D3E2H96p.mjs +648 -0
- package/dist/router-B7J4YYwg.mjs +418 -0
- package/dist/router-BcUmg1kB.d.mts +27 -0
- package/dist/runtime-context-B5pREhcM.mjs +164 -0
- package/dist/runtime-context-ytVd7GmZ.d.mts +72 -0
- package/dist/runtime-middleware-aeBdgjYr.d.mts +77 -0
- package/dist/server.d.mts +5 -0
- package/dist/server.mjs +5 -0
- package/dist/types-idmK5omD.mjs +355 -0
- package/package.json +19 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FunctionComponent } from "preact";
|
|
2
|
+
|
|
3
|
+
//#region src/forwardRef.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Pass ref down to a child. This is mainly used in libraries with HOCs that
|
|
6
|
+
* wrap components. Using `forwardRef` there is an easy way to get a reference
|
|
7
|
+
* of the wrapped component instead of one of the wrapper itself.
|
|
8
|
+
*/
|
|
9
|
+
declare function forwardRef<P = {}>(fn: ((props: P, ref: any) => any) & {
|
|
10
|
+
displayName?: string;
|
|
11
|
+
}): FunctionComponent<P & {
|
|
12
|
+
ref?: any;
|
|
13
|
+
}>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/hydration.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Returns `true` once the initial hydration (including all Suspense
|
|
18
|
+
* boundaries) has fully resolved. During SSR and hydration this returns
|
|
19
|
+
* `false`.
|
|
20
|
+
*/
|
|
21
|
+
declare function useIsHydrated(): boolean;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { forwardRef as n, useIsHydrated as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,439 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { $ as RouteComponentProps, A as HrefRouteDefinition, B as ModuleImporter, C as HeadAttributes, D as HrefArgs, E as HeadersArgs, G as PrachtAppConfig, H as ModuleRegistry, I as MiddlewareArgs, J as Register, K as PrachtHttpError, L as MiddlewareFn, M as LoaderArgs, N as LoaderData, O as HrefFn, P as LoaderFn, Q as ResolvedRoute, R as MiddlewareModule, S as HeadArgs, T as HeadScriptDescriptor, U as NavigateOptions, V as ModuleRef, W as PrachtApp, X as ResolvedApiRoute, Y as RenderMode, Z as ResolvedPrachtApp, _ as BuildHrefOptions, _t as ShellProps, a as matchApiRoute, at as RouteModule, b as GroupDefinition, c as resolveApp, ct as RouteParamsFor, d as ApiConfig, dt as RouteTarget, et as RouteConfig, f as ApiRouteArgs, ft as RouteTreeNode, g as BaseRouteArgs, gt as ShellModule, h as ApiRouteModule, ht as SearchParamsInput, i as group, it as RouteMeta, j as HttpMethod, k as HrefOptions, l as route, lt as RouteRevalidate, m as ApiRouteMatch, mt as SearchParamValue, n as buildPathFromSegments, nt as RouteId, o as matchAppRoute, ot as RouteParamInput, p as ApiRouteHandler, pt as SearchParamPrimitive, q as PrefetchStrategy, r as defineApp, rt as RouteMatch, s as resolveApiRoutes, st as RouteParams, t as buildHref, tt as RouteDefinition, u as timeRevalidate, ut as RouteSearchFor, v as DataModule, vt as TimeRevalidatePolicy, w as HeadMetadata, x as GroupMeta, y as ErrorBoundaryProps, z as MiddlewareNext } from "./app-BWriseLj.mjs";
|
|
2
|
+
import { c as Link, d as useLocation, f as useParams, h as createHref, l as LinkProps, m as useRouteData, n as redirect, o as Form, p as useRevalidate, r as RouteStateResult, s as FormProps, t as RedirectOptions, u as Location } from "./runtime-middleware-aeBdgjYr.mjs";
|
|
3
|
+
import { n as forwardRef, t as useIsHydrated } from "./hydration-M1QzbQ1O.mjs";
|
|
4
|
+
import { a as startApp, c as SerializedRouteError, i as readHydrationState, n as PrachtRuntimeProvider, o as PrachtRuntimeDiagnosticPhase, r as StartAppOptions, s as PrachtRuntimeDiagnostics, t as PrachtHydrationState } from "./runtime-context-ytVd7GmZ.mjs";
|
|
5
|
+
import { i as useNavigate, n as NavigateFn, r as initClientRouter, t as InitClientRouterOptions } from "./router-BcUmg1kB.mjs";
|
|
6
|
+
import { a as prerenderApp, c as applyDefaultSecurityHeaders, i as PrerenderResult, n as PrerenderAppOptions, o as HandlePrachtRequestOptions, r as PrerenderAppResult, s as handlePrachtRequest, t as ISGManifestEntry } from "./prerender-B8_CqYwd.mjs";
|
|
3
7
|
import { Suspense, lazy } from "preact-suspense";
|
|
4
|
-
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Augment this interface to register your app's context type globally.
|
|
8
|
-
* Once registered, all route args (`BaseRouteArgs`, `LoaderArgs`, etc.)
|
|
9
|
-
* will use your context type automatically — no per-file generics needed.
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* // src/env.d.ts
|
|
13
|
-
* declare module "@pracht/core" {
|
|
14
|
-
* interface Register {
|
|
15
|
-
* context: { env: Env; executionContext: ExecutionContext };
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
interface Register {}
|
|
21
|
-
type RegisteredContext = Register extends {
|
|
22
|
-
context: infer T;
|
|
23
|
-
} ? T : unknown;
|
|
24
|
-
type RenderMode = "spa" | "ssr" | "ssg" | "isg";
|
|
25
|
-
type RouteParams = Record<string, string>;
|
|
26
|
-
/**
|
|
27
|
-
* A reference to a module file — either a plain string path or a lazy import
|
|
28
|
-
* function. Using `() => import("./path")` enables IDE click-to-navigate.
|
|
29
|
-
* The vite plugin transforms import functions back to strings at build time.
|
|
30
|
-
*/
|
|
31
|
-
type ModuleRef = string | (() => Promise<any>);
|
|
32
|
-
interface TimeRevalidatePolicy {
|
|
33
|
-
kind: "time";
|
|
34
|
-
seconds: number;
|
|
35
|
-
}
|
|
36
|
-
type RouteRevalidate = TimeRevalidatePolicy;
|
|
37
|
-
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
38
|
-
type ApiRouteArgs<TContext = RegisteredContext> = Omit<BaseRouteArgs<TContext>, "route"> & {
|
|
39
|
-
route: ResolvedApiRoute;
|
|
40
|
-
};
|
|
41
|
-
type ApiRouteHandler<TContext = RegisteredContext> = (args: ApiRouteArgs<TContext>) => MaybePromise<Response>;
|
|
42
|
-
interface ApiRouteModule<TContext = any> {
|
|
43
|
-
default?: ApiRouteHandler<TContext>;
|
|
44
|
-
GET?: ApiRouteHandler<TContext>;
|
|
45
|
-
POST?: ApiRouteHandler<TContext>;
|
|
46
|
-
PUT?: ApiRouteHandler<TContext>;
|
|
47
|
-
PATCH?: ApiRouteHandler<TContext>;
|
|
48
|
-
DELETE?: ApiRouteHandler<TContext>;
|
|
49
|
-
HEAD?: ApiRouteHandler<TContext>;
|
|
50
|
-
OPTIONS?: ApiRouteHandler<TContext>;
|
|
51
|
-
}
|
|
52
|
-
interface ResolvedApiRoute {
|
|
53
|
-
path: string;
|
|
54
|
-
file: string;
|
|
55
|
-
segments: RouteSegment[];
|
|
56
|
-
}
|
|
57
|
-
interface ApiRouteMatch {
|
|
58
|
-
route: ResolvedApiRoute;
|
|
59
|
-
params: RouteParams;
|
|
60
|
-
pathname: string;
|
|
61
|
-
}
|
|
62
|
-
type PrefetchStrategy = "none" | "hover" | "viewport" | "intent";
|
|
63
|
-
interface RouteMeta {
|
|
64
|
-
id?: string;
|
|
65
|
-
shell?: string;
|
|
66
|
-
render?: RenderMode;
|
|
67
|
-
middleware?: string[];
|
|
68
|
-
revalidate?: RouteRevalidate;
|
|
69
|
-
prefetch?: PrefetchStrategy;
|
|
70
|
-
}
|
|
71
|
-
interface GroupMeta {
|
|
72
|
-
shell?: string;
|
|
73
|
-
render?: RenderMode;
|
|
74
|
-
middleware?: string[];
|
|
75
|
-
pathPrefix?: string;
|
|
76
|
-
}
|
|
77
|
-
interface ApiConfig {
|
|
78
|
-
middleware?: string[];
|
|
79
|
-
/**
|
|
80
|
-
* When `true` (the default), state-changing API requests
|
|
81
|
-
* (POST/PUT/PATCH/DELETE) are rejected unless the browser signals an
|
|
82
|
-
* exact same-origin fetch (`Sec-Fetch-Site: same-origin`) or the request
|
|
83
|
-
* Origin/Referer matches the request URL's origin. `same-site` is not
|
|
84
|
-
* accepted by default because sibling subdomains can be attacker-controlled.
|
|
85
|
-
* Set to `false` to opt out if you build your own CSRF protection into middleware.
|
|
86
|
-
*/
|
|
87
|
-
requireSameOrigin?: boolean;
|
|
88
|
-
}
|
|
89
|
-
interface RouteConfig extends RouteMeta {
|
|
90
|
-
component: ModuleRef;
|
|
91
|
-
loader?: ModuleRef;
|
|
92
|
-
}
|
|
93
|
-
interface RouteDefinition extends RouteMeta {
|
|
94
|
-
kind: "route";
|
|
95
|
-
path: string;
|
|
96
|
-
file: string;
|
|
97
|
-
loaderFile?: string;
|
|
98
|
-
}
|
|
99
|
-
interface GroupDefinition {
|
|
100
|
-
kind: "group";
|
|
101
|
-
meta: GroupMeta;
|
|
102
|
-
routes: RouteTreeNode[];
|
|
103
|
-
}
|
|
104
|
-
type RouteTreeNode = RouteDefinition | GroupDefinition;
|
|
105
|
-
interface PrachtAppConfig {
|
|
106
|
-
shells?: Record<string, ModuleRef>;
|
|
107
|
-
middleware?: Record<string, ModuleRef>;
|
|
108
|
-
api?: ApiConfig;
|
|
109
|
-
routes: RouteTreeNode[];
|
|
110
|
-
}
|
|
111
|
-
interface PrachtApp {
|
|
112
|
-
shells: Record<string, string>;
|
|
113
|
-
middleware: Record<string, string>;
|
|
114
|
-
api: ApiConfig;
|
|
115
|
-
routes: RouteTreeNode[];
|
|
116
|
-
}
|
|
117
|
-
interface StaticRouteSegment {
|
|
118
|
-
type: "static";
|
|
119
|
-
value: string;
|
|
120
|
-
}
|
|
121
|
-
interface ParamRouteSegment {
|
|
122
|
-
type: "param";
|
|
123
|
-
name: string;
|
|
124
|
-
}
|
|
125
|
-
interface CatchAllRouteSegment {
|
|
126
|
-
type: "catchall";
|
|
127
|
-
name: string;
|
|
128
|
-
}
|
|
129
|
-
type RouteSegment = StaticRouteSegment | ParamRouteSegment | CatchAllRouteSegment;
|
|
130
|
-
interface ResolvedRoute extends Omit<RouteMeta, "middleware"> {
|
|
131
|
-
path: string;
|
|
132
|
-
file: string;
|
|
133
|
-
loaderFile?: string;
|
|
134
|
-
shell?: string;
|
|
135
|
-
shellFile?: string;
|
|
136
|
-
middleware: string[];
|
|
137
|
-
middlewareFiles: string[];
|
|
138
|
-
segments: RouteSegment[];
|
|
139
|
-
}
|
|
140
|
-
interface ResolvedPrachtApp extends Omit<PrachtApp, "routes"> {
|
|
141
|
-
routes: ResolvedRoute[];
|
|
142
|
-
apiRoutes: ResolvedApiRoute[];
|
|
143
|
-
}
|
|
144
|
-
interface RouteMatch {
|
|
145
|
-
route: ResolvedRoute;
|
|
146
|
-
params: RouteParams;
|
|
147
|
-
pathname: string;
|
|
148
|
-
}
|
|
149
|
-
interface BaseRouteArgs<TContext = RegisteredContext> {
|
|
150
|
-
request: Request;
|
|
151
|
-
params: RouteParams;
|
|
152
|
-
context: TContext;
|
|
153
|
-
signal: AbortSignal;
|
|
154
|
-
url: URL;
|
|
155
|
-
route: ResolvedRoute;
|
|
156
|
-
}
|
|
157
|
-
interface LoaderArgs<TContext = RegisteredContext> extends BaseRouteArgs<TContext> {}
|
|
158
|
-
interface MiddlewareArgs<TContext = RegisteredContext> extends BaseRouteArgs<TContext> {}
|
|
159
|
-
type HeadAttributes = Record<string, string | undefined>;
|
|
160
|
-
interface HeadScriptDescriptor extends HeadAttributes {
|
|
161
|
-
children?: string;
|
|
162
|
-
}
|
|
163
|
-
interface HeadMetadata {
|
|
164
|
-
title?: string;
|
|
165
|
-
lang?: string;
|
|
166
|
-
meta?: HeadAttributes[];
|
|
167
|
-
link?: HeadAttributes[];
|
|
168
|
-
script?: HeadScriptDescriptor[];
|
|
169
|
-
}
|
|
170
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
171
|
-
type LoaderLike = ((args: LoaderArgs<any>) => unknown) | undefined;
|
|
172
|
-
type LoaderData<TLoader extends LoaderLike> = TLoader extends ((...args: any[]) => infer TResult) ? Awaited<TResult> : never;
|
|
173
|
-
interface HeadArgs<TLoader extends LoaderLike = undefined, TContext = any> extends BaseRouteArgs<TContext> {
|
|
174
|
-
data: LoaderData<TLoader>;
|
|
175
|
-
}
|
|
176
|
-
interface HeadersArgs<TLoader extends LoaderLike = undefined, TContext = any> extends BaseRouteArgs<TContext> {
|
|
177
|
-
data: LoaderData<TLoader>;
|
|
178
|
-
}
|
|
179
|
-
interface RouteComponentProps<TLoader extends LoaderLike = undefined> {
|
|
180
|
-
data: LoaderData<TLoader>;
|
|
181
|
-
params: RouteParams;
|
|
182
|
-
}
|
|
183
|
-
interface ErrorBoundaryProps {
|
|
184
|
-
error: Error & {
|
|
185
|
-
diagnostics?: unknown;
|
|
186
|
-
status?: number;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
interface ShellProps {
|
|
190
|
-
children: ComponentChildren;
|
|
191
|
-
}
|
|
192
|
-
type LoaderFn<TContext = any, TData = unknown> = (args: LoaderArgs<TContext>) => MaybePromise<TData>;
|
|
193
|
-
interface RouteModule<TContext = any, TLoader extends LoaderLike = undefined> {
|
|
194
|
-
loader?: LoaderFn<TContext>;
|
|
195
|
-
head?: (args: HeadArgs<TLoader, TContext>) => MaybePromise<HeadMetadata>;
|
|
196
|
-
headers?: (args: HeadersArgs<TLoader, TContext>) => MaybePromise<HeadersInit>;
|
|
197
|
-
Component?: FunctionComponent<RouteComponentProps<TLoader>>;
|
|
198
|
-
default?: FunctionComponent<RouteComponentProps<TLoader>>;
|
|
199
|
-
ErrorBoundary?: FunctionComponent<ErrorBoundaryProps>;
|
|
200
|
-
getStaticPaths?: () => MaybePromise<RouteParams[]>;
|
|
201
|
-
markdown?: string;
|
|
202
|
-
}
|
|
203
|
-
interface ShellModule<TContext = any> {
|
|
204
|
-
Shell: FunctionComponent<ShellProps>;
|
|
205
|
-
Loading?: FunctionComponent;
|
|
206
|
-
ErrorBoundary?: FunctionComponent<ErrorBoundaryProps>;
|
|
207
|
-
head?: (args: BaseRouteArgs<TContext>) => MaybePromise<HeadMetadata>;
|
|
208
|
-
headers?: (args: BaseRouteArgs<TContext>) => MaybePromise<HeadersInit>;
|
|
209
|
-
}
|
|
210
|
-
type MiddlewareResult<TContext = any> = void | Response | {
|
|
211
|
-
redirect: string;
|
|
212
|
-
status?: number;
|
|
213
|
-
} | {
|
|
214
|
-
context: Partial<TContext>;
|
|
215
|
-
};
|
|
216
|
-
type MiddlewareFn<TContext = any> = (args: MiddlewareArgs<TContext>) => MaybePromise<MiddlewareResult<TContext>>;
|
|
217
|
-
interface MiddlewareModule<TContext = any> {
|
|
218
|
-
middleware: MiddlewareFn<TContext>;
|
|
219
|
-
}
|
|
220
|
-
type ModuleImporter<TModule = unknown> = () => Promise<TModule>;
|
|
221
|
-
interface DataModule<TContext = any> {
|
|
222
|
-
loader?: LoaderFn<TContext>;
|
|
223
|
-
}
|
|
224
|
-
interface ModuleRegistry {
|
|
225
|
-
routeModules?: Record<string, ModuleImporter<RouteModule>>;
|
|
226
|
-
shellModules?: Record<string, ModuleImporter<ShellModule>>;
|
|
227
|
-
middlewareModules?: Record<string, ModuleImporter<MiddlewareModule>>;
|
|
228
|
-
apiModules?: Record<string, ModuleImporter<ApiRouteModule>>;
|
|
229
|
-
dataModules?: Record<string, ModuleImporter<DataModule>>;
|
|
230
|
-
}
|
|
231
|
-
declare class PrachtHttpError extends Error {
|
|
232
|
-
readonly status: number;
|
|
233
|
-
constructor(status: number, message: string);
|
|
234
|
-
}
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/app.d.ts
|
|
237
|
-
declare function timeRevalidate(seconds: number): TimeRevalidatePolicy;
|
|
238
|
-
declare function route(path: string, file: ModuleRef, meta?: RouteMeta): RouteDefinition;
|
|
239
|
-
declare function route(path: string, config: RouteConfig): RouteDefinition;
|
|
240
|
-
declare function group(meta: GroupMeta, routes: RouteTreeNode[]): GroupDefinition;
|
|
241
|
-
declare function defineApp(config: PrachtAppConfig): PrachtApp;
|
|
242
|
-
declare function resolveApp(app: PrachtApp): ResolvedPrachtApp;
|
|
243
|
-
declare function matchAppRoute(app: PrachtApp | ResolvedPrachtApp, pathname: string): RouteMatch | undefined;
|
|
244
|
-
declare function buildPathFromSegments(segments: RouteSegment[], params: RouteParams): string;
|
|
245
|
-
/**
|
|
246
|
-
* Convert a list of file paths from `import.meta.glob` into resolved API routes.
|
|
247
|
-
*
|
|
248
|
-
* Example: `"/src/api/health.ts"` → path `/api/health`
|
|
249
|
-
* `"/src/api/users/[id].ts"` → path `/api/users/:id`
|
|
250
|
-
* `"/src/api/files/[...path].ts"` → path `/api/files/*`
|
|
251
|
-
* `"/src/api/index.ts"` → path `/api`
|
|
252
|
-
*/
|
|
253
|
-
declare function resolveApiRoutes(files: string[], apiDir?: string): ResolvedApiRoute[];
|
|
254
|
-
declare function matchApiRoute(apiRoutes: ResolvedApiRoute[], pathname: string): ApiRouteMatch | undefined;
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/forwardRef.d.ts
|
|
257
|
-
/**
|
|
258
|
-
* Pass ref down to a child. This is mainly used in libraries with HOCs that
|
|
259
|
-
* wrap components. Using `forwardRef` there is an easy way to get a reference
|
|
260
|
-
* of the wrapped component instead of one of the wrapper itself.
|
|
261
|
-
*/
|
|
262
|
-
declare function forwardRef<P = {}>(fn: ((props: P, ref: any) => any) & {
|
|
263
|
-
displayName?: string;
|
|
264
|
-
}): FunctionComponent<P & {
|
|
265
|
-
ref?: any;
|
|
266
|
-
}>;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/hydration.d.ts
|
|
269
|
-
/**
|
|
270
|
-
* Returns `true` once the initial hydration (including all Suspense
|
|
271
|
-
* boundaries) has fully resolved. During SSR and hydration this returns
|
|
272
|
-
* `false`.
|
|
273
|
-
*/
|
|
274
|
-
declare function useIsHydrated(): boolean;
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/runtime-headers.d.ts
|
|
277
|
-
declare function applyDefaultSecurityHeaders(headers: Headers): Headers;
|
|
278
|
-
//#endregion
|
|
279
|
-
//#region src/runtime-errors.d.ts
|
|
280
|
-
type PrachtRuntimeDiagnosticPhase = "match" | "middleware" | "loader" | "action" | "render" | "api";
|
|
281
|
-
interface PrachtRuntimeDiagnostics {
|
|
282
|
-
phase: PrachtRuntimeDiagnosticPhase;
|
|
283
|
-
routeId?: string;
|
|
284
|
-
routePath?: string;
|
|
285
|
-
routeFile?: string;
|
|
286
|
-
loaderFile?: string;
|
|
287
|
-
shellFile?: string;
|
|
288
|
-
middlewareFiles?: string[];
|
|
289
|
-
status: number;
|
|
290
|
-
}
|
|
291
|
-
interface SerializedRouteError {
|
|
292
|
-
message: string;
|
|
293
|
-
name: string;
|
|
294
|
-
status: number;
|
|
295
|
-
diagnostics?: PrachtRuntimeDiagnostics;
|
|
296
|
-
}
|
|
297
|
-
//#endregion
|
|
298
|
-
//#region src/runtime-hooks.d.ts
|
|
299
|
-
interface PrachtHydrationState<TData = unknown> {
|
|
300
|
-
url: string;
|
|
301
|
-
routeId: string;
|
|
302
|
-
data: TData;
|
|
303
|
-
error?: SerializedRouteError | null;
|
|
304
|
-
pending?: boolean;
|
|
305
|
-
}
|
|
306
|
-
interface StartAppOptions<TData = unknown> {
|
|
307
|
-
initialData?: TData;
|
|
308
|
-
}
|
|
309
|
-
interface FormProps extends Omit<JSX.HTMLAttributes<HTMLFormElement>, "action" | "method"> {
|
|
310
|
-
action?: string;
|
|
311
|
-
method?: string;
|
|
312
|
-
}
|
|
313
|
-
interface Location {
|
|
314
|
-
pathname: string;
|
|
315
|
-
search: string;
|
|
316
|
-
}
|
|
317
|
-
declare global {
|
|
318
|
-
interface Window {
|
|
319
|
-
__PRACHT_STATE__?: PrachtHydrationState;
|
|
320
|
-
__PRACHT_NAVIGATE__?: (to: string, options?: {
|
|
321
|
-
replace?: boolean;
|
|
322
|
-
}) => Promise<void>;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
interface PrachtRuntimeValue {
|
|
326
|
-
data: unknown;
|
|
327
|
-
params: RouteParams;
|
|
328
|
-
routeId: string;
|
|
329
|
-
url: string;
|
|
330
|
-
setData: (data: unknown) => void;
|
|
331
|
-
}
|
|
332
|
-
declare function PrachtRuntimeProvider<TData>({
|
|
333
|
-
children,
|
|
334
|
-
data,
|
|
335
|
-
params,
|
|
336
|
-
routeId,
|
|
337
|
-
stateVersion,
|
|
338
|
-
url
|
|
339
|
-
}: {
|
|
340
|
-
children: ComponentChildren;
|
|
341
|
-
data: TData;
|
|
342
|
-
params?: RouteParams;
|
|
343
|
-
routeId: string;
|
|
344
|
-
stateVersion?: number;
|
|
345
|
-
url: string;
|
|
346
|
-
}): _$preact.VNode<_$preact.Attributes & {
|
|
347
|
-
value: PrachtRuntimeValue | undefined;
|
|
348
|
-
children?: ComponentChildren;
|
|
349
|
-
}>;
|
|
350
|
-
declare function startApp<TData = unknown>(options?: StartAppOptions<TData>): TData | undefined;
|
|
351
|
-
declare function readHydrationState<TData = unknown>(): PrachtHydrationState<TData> | undefined;
|
|
352
|
-
declare function useRouteData<TLoader extends LoaderLike>(): LoaderData<TLoader>;
|
|
353
|
-
declare function useRouteData<TData = unknown>(): TData;
|
|
354
|
-
declare function useLocation(): Location;
|
|
355
|
-
declare function useParams(): RouteParams;
|
|
356
|
-
declare function useRevalidate(): () => Promise<unknown>;
|
|
357
|
-
declare function Form(props: FormProps): _$preact.VNode<_$preact.ClassAttributes<HTMLFormElement> & h.JSX.HTMLAttributes<HTMLFormElement>>;
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region src/runtime-client-fetch.d.ts
|
|
360
|
-
type RouteStateResult = {
|
|
361
|
-
type: "data";
|
|
362
|
-
data: unknown;
|
|
363
|
-
} | {
|
|
364
|
-
type: "redirect";
|
|
365
|
-
location: string;
|
|
366
|
-
} | {
|
|
367
|
-
type: "error";
|
|
368
|
-
error: SerializedRouteError;
|
|
369
|
-
};
|
|
370
|
-
//#endregion
|
|
371
|
-
//#region src/runtime.d.ts
|
|
372
|
-
interface HandlePrachtRequestOptions<TContext = unknown> {
|
|
373
|
-
app: PrachtApp;
|
|
374
|
-
request: Request;
|
|
375
|
-
context?: TContext;
|
|
376
|
-
registry?: ModuleRegistry;
|
|
377
|
-
/** Expose raw server error details in rendered HTML and route-state JSON. */
|
|
378
|
-
debugErrors?: boolean;
|
|
379
|
-
clientEntryUrl?: string;
|
|
380
|
-
/** Per-source-file CSS map produced by the vite plugin. */
|
|
381
|
-
cssManifest?: Record<string, string[]>;
|
|
382
|
-
/** Per-source-file JS chunk map produced by the vite plugin for modulepreload hints. */
|
|
383
|
-
jsManifest?: Record<string, string[]>;
|
|
384
|
-
apiRoutes?: ResolvedApiRoute[];
|
|
385
|
-
}
|
|
386
|
-
declare function handlePrachtRequest<TContext>(options: HandlePrachtRequestOptions<TContext>): Promise<Response>;
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region src/prerender.d.ts
|
|
389
|
-
interface PrerenderResult {
|
|
390
|
-
path: string;
|
|
391
|
-
html: string;
|
|
392
|
-
headers?: Record<string, string>;
|
|
393
|
-
}
|
|
394
|
-
interface ISGManifestEntry {
|
|
395
|
-
revalidate: RouteRevalidate;
|
|
396
|
-
}
|
|
397
|
-
interface PrerenderAppResult {
|
|
398
|
-
pages: PrerenderResult[];
|
|
399
|
-
isgManifest: Record<string, ISGManifestEntry>;
|
|
400
|
-
}
|
|
401
|
-
interface PrerenderAppOptions {
|
|
402
|
-
app: PrachtApp;
|
|
403
|
-
registry?: ModuleRegistry;
|
|
404
|
-
clientEntryUrl?: string;
|
|
405
|
-
/** Per-source-file CSS map produced by the vite plugin. */
|
|
406
|
-
cssManifest?: Record<string, string[]>;
|
|
407
|
-
/** Per-source-file JS map produced by the vite plugin for modulepreload hints. */
|
|
408
|
-
jsManifest?: Record<string, string[]>;
|
|
409
|
-
/** Maximum number of pages rendered concurrently. Defaults to 10. */
|
|
410
|
-
concurrency?: number;
|
|
411
|
-
}
|
|
412
|
-
declare function prerenderApp(options: PrerenderAppOptions): Promise<PrerenderResult[]>;
|
|
413
|
-
declare function prerenderApp(options: PrerenderAppOptions & {
|
|
414
|
-
withISGManifest: true;
|
|
415
|
-
}): Promise<PrerenderAppResult>;
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/router.d.ts
|
|
418
|
-
declare global {
|
|
419
|
-
interface Window {
|
|
420
|
-
__PRACHT_NAVIGATE__?: NavigateFn;
|
|
421
|
-
__PRACHT_ROUTER_READY__?: boolean;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
type ModuleMap = Record<string, () => Promise<unknown>>;
|
|
425
|
-
type NavigateFn = (to: string, options?: {
|
|
426
|
-
replace?: boolean;
|
|
427
|
-
}) => Promise<void>;
|
|
428
|
-
declare function useNavigate(): NavigateFn;
|
|
429
|
-
interface InitClientRouterOptions {
|
|
430
|
-
app: ResolvedPrachtApp;
|
|
431
|
-
routeModules: ModuleMap;
|
|
432
|
-
shellModules: ModuleMap;
|
|
433
|
-
initialState: PrachtHydrationState;
|
|
434
|
-
root: HTMLElement;
|
|
435
|
-
findModuleKey: (modules: ModuleMap, file: string) => string | null;
|
|
436
|
-
}
|
|
437
|
-
declare function initClientRouter(options: InitClientRouterOptions): Promise<void>;
|
|
438
|
-
//#endregion
|
|
439
|
-
export { type ApiConfig, type ApiRouteArgs, type ApiRouteHandler, type ApiRouteMatch, type ApiRouteModule, type BaseRouteArgs, type DataModule, type ErrorBoundaryProps, Form, type FormProps, type GroupDefinition, type GroupMeta, type HandlePrachtRequestOptions, type HeadArgs, type HeadAttributes, type HeadMetadata, type HeadScriptDescriptor, type HeadersArgs, type HttpMethod, type ISGManifestEntry, type InitClientRouterOptions, type LoaderArgs, type LoaderData, type LoaderFn, type Location, type MiddlewareArgs, type MiddlewareFn, type MiddlewareModule, type MiddlewareResult, type ModuleImporter, type ModuleRef, type ModuleRegistry, type NavigateFn, type PrachtApp, type PrachtAppConfig, PrachtHttpError, type PrachtHydrationState, type PrachtRuntimeDiagnosticPhase, type PrachtRuntimeDiagnostics, PrachtRuntimeProvider, type PrefetchStrategy, type PrerenderAppOptions, type PrerenderAppResult, type PrerenderResult, type Register, type RenderMode, type ResolvedApiRoute, type ResolvedPrachtApp, type ResolvedRoute, type RouteComponentProps, type RouteConfig, type RouteDefinition, type RouteMatch, type RouteMeta, type RouteModule, type RouteParams, type RouteRevalidate, type RouteStateResult, type RouteTreeNode, type SerializedRouteError, type ShellModule, type ShellProps, type StartAppOptions, Suspense, type TimeRevalidatePolicy, applyDefaultSecurityHeaders, buildPathFromSegments, defineApp, forwardRef, group, handlePrachtRequest, initClientRouter, lazy, matchApiRoute, matchAppRoute, prerenderApp, readHydrationState, resolveApiRoutes, resolveApp, route, startApp, timeRevalidate, useIsHydrated, useLocation, useNavigate, useParams, useRevalidate, useRouteData };
|
|
8
|
+
export { type ApiConfig, type ApiRouteArgs, type ApiRouteHandler, type ApiRouteMatch, type ApiRouteModule, type BaseRouteArgs, type BuildHrefOptions, type DataModule, type ErrorBoundaryProps, Form, type FormProps, type GroupDefinition, type GroupMeta, type HandlePrachtRequestOptions, type HeadArgs, type HeadAttributes, type HeadMetadata, type HeadScriptDescriptor, type HeadersArgs, type HrefArgs, type HrefFn, type HrefOptions, type HrefRouteDefinition, type HttpMethod, type ISGManifestEntry, type InitClientRouterOptions, Link, type LinkProps, type LoaderArgs, type LoaderData, type LoaderFn, type Location, type MiddlewareArgs, type MiddlewareFn, type MiddlewareModule, type MiddlewareNext, type ModuleImporter, type ModuleRef, type ModuleRegistry, type NavigateFn, type NavigateOptions, type PrachtApp, type PrachtAppConfig, PrachtHttpError, type PrachtHydrationState, type PrachtRuntimeDiagnosticPhase, type PrachtRuntimeDiagnostics, PrachtRuntimeProvider, type PrefetchStrategy, type PrerenderAppOptions, type PrerenderAppResult, type PrerenderResult, type RedirectOptions, type Register, type RenderMode, type ResolvedApiRoute, type ResolvedPrachtApp, type ResolvedRoute, type RouteComponentProps, type RouteConfig, type RouteDefinition, type RouteId, type RouteMatch, type RouteMeta, type RouteModule, type RouteParamInput, type RouteParams, type RouteParamsFor, type RouteRevalidate, type RouteSearchFor, type RouteStateResult, type RouteTarget, type RouteTreeNode, type SearchParamPrimitive, type SearchParamValue, type SearchParamsInput, type SerializedRouteError, type ShellModule, type ShellProps, type StartAppOptions, Suspense, type TimeRevalidatePolicy, applyDefaultSecurityHeaders, buildHref, buildPathFromSegments, createHref, defineApp, forwardRef, group, handlePrachtRequest, initClientRouter, lazy, matchApiRoute, matchAppRoute, prerenderApp, readHydrationState, redirect, resolveApiRoutes, resolveApp, route, startApp, timeRevalidate, useIsHydrated, useLocation, useNavigate, useParams, useRevalidate, useRouteData };
|