@pracht/core 0.2.7 → 0.3.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/index.d.mts +46 -26
- package/dist/index.mjs +739 -493
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,14 @@ interface GroupMeta {
|
|
|
76
76
|
}
|
|
77
77
|
interface ApiConfig {
|
|
78
78
|
middleware?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* When `true` (the default), state-changing API requests
|
|
81
|
+
* (POST/PUT/PATCH/DELETE) are rejected unless the browser signals a
|
|
82
|
+
* same-origin/same-site fetch (Sec-Fetch-Site) or the request Origin
|
|
83
|
+
* matches the request URL's origin. Set to `false` to opt out if you
|
|
84
|
+
* build your own CSRF protection into middleware.
|
|
85
|
+
*/
|
|
86
|
+
requireSameOrigin?: boolean;
|
|
79
87
|
}
|
|
80
88
|
interface RouteConfig extends RouteMeta {
|
|
81
89
|
component: ModuleRef;
|
|
@@ -181,6 +189,7 @@ interface RouteModule<TContext = any, TLoader extends LoaderLike = undefined> {
|
|
|
181
189
|
default?: FunctionComponent<RouteComponentProps<TLoader>>;
|
|
182
190
|
ErrorBoundary?: FunctionComponent<ErrorBoundaryProps>;
|
|
183
191
|
getStaticPaths?: () => MaybePromise<RouteParams[]>;
|
|
192
|
+
markdown?: string;
|
|
184
193
|
}
|
|
185
194
|
interface ShellModule<TContext = any> {
|
|
186
195
|
Shell: FunctionComponent<ShellProps>;
|
|
@@ -190,6 +199,7 @@ interface ShellModule<TContext = any> {
|
|
|
190
199
|
}
|
|
191
200
|
type MiddlewareResult<TContext = any> = void | Response | {
|
|
192
201
|
redirect: string;
|
|
202
|
+
status?: number;
|
|
193
203
|
} | {
|
|
194
204
|
context: Partial<TContext>;
|
|
195
205
|
};
|
|
@@ -252,7 +262,10 @@ declare function forwardRef<P = {}>(fn: ((props: P, ref: any) => any) & {
|
|
|
252
262
|
*/
|
|
253
263
|
declare function useIsHydrated(): boolean;
|
|
254
264
|
//#endregion
|
|
255
|
-
//#region src/runtime.d.ts
|
|
265
|
+
//#region src/runtime-headers.d.ts
|
|
266
|
+
declare function applyDefaultSecurityHeaders(headers: Headers): Headers;
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/runtime-errors.d.ts
|
|
256
269
|
type PrachtRuntimeDiagnosticPhase = "match" | "middleware" | "loader" | "action" | "render" | "api";
|
|
257
270
|
interface PrachtRuntimeDiagnostics {
|
|
258
271
|
phase: PrachtRuntimeDiagnosticPhase;
|
|
@@ -264,6 +277,14 @@ interface PrachtRuntimeDiagnostics {
|
|
|
264
277
|
middlewareFiles?: string[];
|
|
265
278
|
status: number;
|
|
266
279
|
}
|
|
280
|
+
interface SerializedRouteError {
|
|
281
|
+
message: string;
|
|
282
|
+
name: string;
|
|
283
|
+
status: number;
|
|
284
|
+
diagnostics?: PrachtRuntimeDiagnostics;
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/runtime-hooks.d.ts
|
|
267
288
|
interface PrachtHydrationState<TData = unknown> {
|
|
268
289
|
url: string;
|
|
269
290
|
routeId: string;
|
|
@@ -271,33 +292,17 @@ interface PrachtHydrationState<TData = unknown> {
|
|
|
271
292
|
error?: SerializedRouteError | null;
|
|
272
293
|
pending?: boolean;
|
|
273
294
|
}
|
|
274
|
-
interface SerializedRouteError {
|
|
275
|
-
message: string;
|
|
276
|
-
name: string;
|
|
277
|
-
status: number;
|
|
278
|
-
diagnostics?: PrachtRuntimeDiagnostics;
|
|
279
|
-
}
|
|
280
295
|
interface StartAppOptions<TData = unknown> {
|
|
281
296
|
initialData?: TData;
|
|
282
297
|
}
|
|
283
|
-
interface HandlePrachtRequestOptions<TContext = unknown> {
|
|
284
|
-
app: PrachtApp;
|
|
285
|
-
request: Request;
|
|
286
|
-
context?: TContext;
|
|
287
|
-
registry?: ModuleRegistry;
|
|
288
|
-
/** Expose raw server error details in rendered HTML and route-state JSON. */
|
|
289
|
-
debugErrors?: boolean;
|
|
290
|
-
clientEntryUrl?: string;
|
|
291
|
-
/** Per-source-file CSS map produced by the vite plugin. */
|
|
292
|
-
cssManifest?: Record<string, string[]>;
|
|
293
|
-
/** Per-source-file JS chunk map produced by the vite plugin for modulepreload hints. */
|
|
294
|
-
jsManifest?: Record<string, string[]>;
|
|
295
|
-
apiRoutes?: ResolvedApiRoute[];
|
|
296
|
-
}
|
|
297
298
|
interface FormProps extends Omit<JSX.HTMLAttributes<HTMLFormElement>, "action" | "method"> {
|
|
298
299
|
action?: string;
|
|
299
300
|
method?: string;
|
|
300
301
|
}
|
|
302
|
+
interface Location {
|
|
303
|
+
pathname: string;
|
|
304
|
+
search: string;
|
|
305
|
+
}
|
|
301
306
|
declare global {
|
|
302
307
|
interface Window {
|
|
303
308
|
__PRACHT_STATE__?: PrachtHydrationState;
|
|
@@ -334,14 +339,12 @@ declare function PrachtRuntimeProvider<TData>({
|
|
|
334
339
|
declare function startApp<TData = unknown>(options?: StartAppOptions<TData>): TData | undefined;
|
|
335
340
|
declare function readHydrationState<TData = unknown>(): PrachtHydrationState<TData> | undefined;
|
|
336
341
|
declare function useRouteData<TData = unknown>(): TData;
|
|
337
|
-
interface Location {
|
|
338
|
-
pathname: string;
|
|
339
|
-
search: string;
|
|
340
|
-
}
|
|
341
342
|
declare function useLocation(): Location;
|
|
342
343
|
declare function useParams(): RouteParams;
|
|
343
344
|
declare function useRevalidate(): () => Promise<unknown>;
|
|
344
345
|
declare function Form(props: FormProps): _$preact.VNode<_$preact.ClassAttributes<HTMLFormElement> & h.JSX.HTMLAttributes<HTMLFormElement>>;
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/runtime-client-fetch.d.ts
|
|
345
348
|
type RouteStateResult = {
|
|
346
349
|
type: "data";
|
|
347
350
|
data: unknown;
|
|
@@ -352,8 +355,25 @@ type RouteStateResult = {
|
|
|
352
355
|
type: "error";
|
|
353
356
|
error: SerializedRouteError;
|
|
354
357
|
};
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/runtime.d.ts
|
|
360
|
+
interface HandlePrachtRequestOptions<TContext = unknown> {
|
|
361
|
+
app: PrachtApp;
|
|
362
|
+
request: Request;
|
|
363
|
+
context?: TContext;
|
|
364
|
+
registry?: ModuleRegistry;
|
|
365
|
+
/** Expose raw server error details in rendered HTML and route-state JSON. */
|
|
366
|
+
debugErrors?: boolean;
|
|
367
|
+
clientEntryUrl?: string;
|
|
368
|
+
/** Per-source-file CSS map produced by the vite plugin. */
|
|
369
|
+
cssManifest?: Record<string, string[]>;
|
|
370
|
+
/** Per-source-file JS chunk map produced by the vite plugin for modulepreload hints. */
|
|
371
|
+
jsManifest?: Record<string, string[]>;
|
|
372
|
+
apiRoutes?: ResolvedApiRoute[];
|
|
373
|
+
}
|
|
355
374
|
declare function handlePrachtRequest<TContext>(options: HandlePrachtRequestOptions<TContext>): Promise<Response>;
|
|
356
|
-
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/prerender.d.ts
|
|
357
377
|
interface PrerenderResult {
|
|
358
378
|
path: string;
|
|
359
379
|
html: string;
|