We're having a growing number of packages in this repository. This PR moves them into a `packages/` directory like it's commonly done in other projects.
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import type { ComponentChildren } from "preact";
|
|
import type { Context } from "./context.ts";
|
|
import type { PageProps } from "./render.ts";
|
|
import type { HandlerFn, RouteHandler } from "./handlers.ts";
|
|
|
|
/**
|
|
* @deprecated Use {@linkcode PageProps} instead.
|
|
*/
|
|
export type AppProps<_Data = unknown, T = unknown> = Context<T>;
|
|
/**
|
|
* @deprecated Use {@linkcode PageProps} instead.
|
|
*/
|
|
export type LayoutProps<_Data = unknown, T = unknown> = Context<T>;
|
|
/**
|
|
* @deprecated Use {@linkcode PageProps} instead.
|
|
*/
|
|
export type UnknownPageProps<_Data = unknown, T = unknown> = Context<T>;
|
|
/**
|
|
* @deprecated Use {@linkcode PageProps} instead.
|
|
*/
|
|
export type ErrorPageProps<_Data = unknown, T = unknown> = Context<T>;
|
|
|
|
/**
|
|
* @deprecated Use {@linkcode FreshContext} instead.
|
|
*/
|
|
export type RouteContext<_T = never, S = Record<string, unknown>> = Context<S>;
|
|
|
|
/**
|
|
* @deprecated Use {@linkcode RouteHandler} instead.
|
|
*/
|
|
// deno-lint-ignore no-explicit-any
|
|
export type Handlers<T = any, State = Record<string, unknown>> = RouteHandler<
|
|
T,
|
|
State
|
|
>;
|
|
|
|
/**
|
|
* @deprecated Use {@linkcode HandlerFn} instead.
|
|
*/
|
|
// deno-lint-ignore no-explicit-any
|
|
export type Handler<T = any, State = Record<string, unknown>> = HandlerFn<
|
|
T,
|
|
State
|
|
>;
|
|
|
|
function defineFn<State>(
|
|
fn: (
|
|
ctx: PageProps<State>,
|
|
) =>
|
|
| ComponentChildren
|
|
| Response
|
|
| Promise<Response | ComponentChildren>,
|
|
): (
|
|
ctx: PageProps<State>,
|
|
) =>
|
|
| ComponentChildren
|
|
| Response
|
|
| Promise<Response | ComponentChildren> {
|
|
return fn;
|
|
}
|
|
|
|
/**
|
|
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
|
|
*/
|
|
export const defineApp = defineFn;
|
|
/**
|
|
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
|
|
*/
|
|
export const defineRoute = defineFn;
|
|
/**
|
|
* @deprecated Use {@linkcode [./mod.ts].Define.page|define.page} instead.
|
|
*/
|
|
export const defineLayout = defineFn;
|