@pracht/core 0.2.7 → 0.4.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 +47 -26
- package/dist/index.mjs +741 -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
|
};
|
|
@@ -227,6 +237,7 @@ declare function buildPathFromSegments(segments: RouteSegment[], params: RoutePa
|
|
|
227
237
|
*
|
|
228
238
|
* Example: `"/src/api/health.ts"` → path `/api/health`
|
|
229
239
|
* `"/src/api/users/[id].ts"` → path `/api/users/:id`
|
|
240
|
+
* `"/src/api/files/[...path].ts"` → path `/api/files/*`
|
|
230
241
|
* `"/src/api/index.ts"` → path `/api`
|
|
231
242
|
*/
|
|
232
243
|
declare function resolveApiRoutes(files: string[], apiDir?: string): ResolvedApiRoute[];
|
|
@@ -252,7 +263,10 @@ declare function forwardRef<P = {}>(fn: ((props: P, ref: any) => any) & {
|
|
|
252
263
|
*/
|
|
253
264
|
declare function useIsHydrated(): boolean;
|
|
254
265
|
//#endregion
|
|
255
|
-
//#region src/runtime.d.ts
|
|
266
|
+
//#region src/runtime-headers.d.ts
|
|
267
|
+
declare function applyDefaultSecurityHeaders(headers: Headers): Headers;
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/runtime-errors.d.ts
|
|
256
270
|
type PrachtRuntimeDiagnosticPhase = "match" | "middleware" | "loader" | "action" | "render" | "api";
|
|
257
271
|
interface PrachtRuntimeDiagnostics {
|
|
258
272
|
phase: PrachtRuntimeDiagnosticPhase;
|
|
@@ -264,6 +278,14 @@ interface PrachtRuntimeDiagnostics {
|
|
|
264
278
|
middlewareFiles?: string[];
|
|
265
279
|
status: number;
|
|
266
280
|
}
|
|
281
|
+
interface SerializedRouteError {
|
|
282
|
+
message: string;
|
|
283
|
+
name: string;
|
|
284
|
+
status: number;
|
|
285
|
+
diagnostics?: PrachtRuntimeDiagnostics;
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/runtime-hooks.d.ts
|
|
267
289
|
interface PrachtHydrationState<TData = unknown> {
|
|
268
290
|
url: string;
|
|
269
291
|
routeId: string;
|
|
@@ -271,33 +293,17 @@ interface PrachtHydrationState<TData = unknown> {
|
|
|
271
293
|
error?: SerializedRouteError | null;
|
|
272
294
|
pending?: boolean;
|
|
273
295
|
}
|
|
274
|
-
interface SerializedRouteError {
|
|
275
|
-
message: string;
|
|
276
|
-
name: string;
|
|
277
|
-
status: number;
|
|
278
|
-
diagnostics?: PrachtRuntimeDiagnostics;
|
|
279
|
-
}
|
|
280
296
|
interface StartAppOptions<TData = unknown> {
|
|
281
297
|
initialData?: TData;
|
|
282
298
|
}
|
|
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
299
|
interface FormProps extends Omit<JSX.HTMLAttributes<HTMLFormElement>, "action" | "method"> {
|
|
298
300
|
action?: string;
|
|
299
301
|
method?: string;
|
|
300
302
|
}
|
|
303
|
+
interface Location {
|
|
304
|
+
pathname: string;
|
|
305
|
+
search: string;
|
|
306
|
+
}
|
|
301
307
|
declare global {
|
|
302
308
|
interface Window {
|
|
303
309
|
__PRACHT_STATE__?: PrachtHydrationState;
|
|
@@ -334,14 +340,12 @@ declare function PrachtRuntimeProvider<TData>({
|
|
|
334
340
|
declare function startApp<TData = unknown>(options?: StartAppOptions<TData>): TData | undefined;
|
|
335
341
|
declare function readHydrationState<TData = unknown>(): PrachtHydrationState<TData> | undefined;
|
|
336
342
|
declare function useRouteData<TData = unknown>(): TData;
|
|
337
|
-
interface Location {
|
|
338
|
-
pathname: string;
|
|
339
|
-
search: string;
|
|
340
|
-
}
|
|
341
343
|
declare function useLocation(): Location;
|
|
342
344
|
declare function useParams(): RouteParams;
|
|
343
345
|
declare function useRevalidate(): () => Promise<unknown>;
|
|
344
346
|
declare function Form(props: FormProps): _$preact.VNode<_$preact.ClassAttributes<HTMLFormElement> & h.JSX.HTMLAttributes<HTMLFormElement>>;
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/runtime-client-fetch.d.ts
|
|
345
349
|
type RouteStateResult = {
|
|
346
350
|
type: "data";
|
|
347
351
|
data: unknown;
|
|
@@ -352,8 +356,25 @@ type RouteStateResult = {
|
|
|
352
356
|
type: "error";
|
|
353
357
|
error: SerializedRouteError;
|
|
354
358
|
};
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/runtime.d.ts
|
|
361
|
+
interface HandlePrachtRequestOptions<TContext = unknown> {
|
|
362
|
+
app: PrachtApp;
|
|
363
|
+
request: Request;
|
|
364
|
+
context?: TContext;
|
|
365
|
+
registry?: ModuleRegistry;
|
|
366
|
+
/** Expose raw server error details in rendered HTML and route-state JSON. */
|
|
367
|
+
debugErrors?: boolean;
|
|
368
|
+
clientEntryUrl?: string;
|
|
369
|
+
/** Per-source-file CSS map produced by the vite plugin. */
|
|
370
|
+
cssManifest?: Record<string, string[]>;
|
|
371
|
+
/** Per-source-file JS chunk map produced by the vite plugin for modulepreload hints. */
|
|
372
|
+
jsManifest?: Record<string, string[]>;
|
|
373
|
+
apiRoutes?: ResolvedApiRoute[];
|
|
374
|
+
}
|
|
355
375
|
declare function handlePrachtRequest<TContext>(options: HandlePrachtRequestOptions<TContext>): Promise<Response>;
|
|
356
|
-
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/prerender.d.ts
|
|
357
378
|
interface PrerenderResult {
|
|
358
379
|
path: string;
|
|
359
380
|
html: string;
|