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