import type { HttpResponse, RequestEvent, TObject, TRet } from "../deps"; import { type EObject, type JSXElement, type JSXProps, type NJSX } from "./index"; type TValue = string | number | TRet; type TContext = { Provider: (props: JSXProps<{ value?: TValue; }>) => Promise; getValue: () => T; }; export declare const s_int: unique symbol; export declare function checkHook(elem: TRet): boolean; /** * createContext. * @example * ```tsx * const MyContext = createContext(); * * app.get("/", () => { * return ( * * // element * * ) * }) * ``` */ export declare function createContext(initValue?: T): TContext; /** * useContext. * @example * ```tsx * const FooContext = createContext(); * * const Home: FC = () => { * const foo = useContext(FooContext); * return

{foo}

* } * * app.get("/", () => { * return ( * * * * ) * }) * ``` */ export declare function useContext(context: TContext): T; export declare const RevContext: TContext; export declare function elemToRevContext(elem: TRet, rev: RequestEvent): Promise; /** * useRequestEvent. server-side only. * @example * ```tsx * const Home: FC = () => { * const rev = useRequestEvent(); * return

{rev.url}

* } * ``` */ export declare const useRequestEvent: () => RequestEvent; export type InternalHook = { sus: TRet[]; sus_id: number; }; export declare const useInternalHook: (rev?: RequestEvent) => InternalHook; /** * useParams. server-side only. * @example * ```tsx * const User: FC = () => { * const params = useParams<{ name: string }>(); * return

{params.name}

* } * ``` */ export declare const useParams: () => T; /** * useQuery. server-side only. * @example * ```tsx * const User: FC = () => { * const query = useQuery<{ name: string }>(); * return

{query.name}

* } * ``` */ export declare const useQuery: () => T; /** * useBody. server-side only. * @example * ```tsx * const User: FC = async () => { * const user = useBody<{ name: string }>(); * // example save user to db. * await user_db.save(user); * return

{user.name}

* } * ``` */ export declare const useBody: () => T; /** * useResponse. server-side only. * @example * ```tsx * const User: FC = () => { * const res = useResponse(); * res.setHeader("name", "john"); * return

hello

* } * ``` */ export declare const useResponse: () => HttpResponse; export declare const useRequest: () => Request; interface AttrScript extends NJSX.ScriptHTMLAttributes { /** * position. default to `footer` */ position?: "head" | "footer"; /** * write script to Helmet. default to `true` */ writeToHelmet?: boolean; } /** * useScript. add client script to the markup. * @example * ```tsx * // without params * const User: FC = () => { * * useScript(() => { * const title = document.getElementById("title") as HTMLElement; * title.innerText = "bar"; * }); * * return

foo

* } * * // with params * const Home: FC = async () => { * const state = { * data: await db.getAll(); * } * * useScript(state, (state) => { * const title = document.getElementById("title") as HTMLElement; * title.innerText = "bar"; * console.log("data from server =>", state.data); * }); * * return

foo

* } * ``` */ export declare function useScript(params: T, js_string: string, options?: AttrScript): string; export declare function useScript(params: T, fn: (params: T) => void | Promise, options?: AttrScript): string; export declare function useScript(fn: (params: T) => void | Promise, params?: T, options?: AttrScript): string; export declare function useScript(js_string: string, params?: T, options?: AttrScript): string; /** * useStyle. server-side only. * @example * ```tsx * const Home: FC = () => { * useStyle({ * ".section": { * backgroundColor: "red" * }, * ".title": { * color: "blue" * } * }); * return ( *
*

title

*
* ) * } * ``` */ export declare function useStyle(css: Record | string, options?: { position?: "head" | "footer"; }): void; /** * generate unique ID. */ export declare const useId: () => string; export declare const createHookScript: (opts?: NJSX.ScriptHTMLAttributes, rev?: RequestEvent) => void; export {};