import type { nothing, TemplateResult } from "lit-html"; import type { Component as ComponentElement } from "./x-x"; export type { Component as ComponentElement } from "./x-x"; /** * HostElement — the x-x custom element instance, augmented with * runtime-added properties from hooks (useSetup, useState, etc.) */ export interface HostElement extends ComponentElement { _setupStack?: any[]; _setupIndex?: number; state?: any; [key: string]: any; } /** * TemplateFn — the inner function returned by a Component. * Called on every render. Returns a lit-html TemplateResult. */ export type TemplateFn = () => TemplateResult | null | typeof nothing; /** * Props — a function that returns the props object of type T. * This is what the Component receives as its argument. * * @example * const props: Props<{ name: string }> = () => ({ name: "Alice" }); */ export type Props> = () => T; /** * Component — a closure function that receives a Props function * and returns a TemplateFn. The outer function runs once on mount; * the returned TemplateFn runs on every render. * * @example * const MyComponent: Component<{ name: string }> = (props) => { * const count = atom(0); * return () => html`
${props().name}: ${count()}
`; * }; */ export type Component = Record> = (propsFn: Props) => TemplateFn; /** * LazyComponent — an async function that returns a module (or a module * with a `default` export) containing a `Component`. Pass one of these * to `x()` or a `Router` config entry to enable code-splitting / lazy loading. * * The runtime detects `isAsyncValue(val) === true`, calls `resolveAsyncValue`, * and then forwards the unwrapped `Component` to the normal render path once * the promise settles. * * @example * // inline with x(): * x(async () => import("./HeavyPage")); * * // inside Router config: * Router([{ path: "/heavy", component: async () => import("./HeavyPage") }]); */ export type LazyComponent = Record> = () => Promise | { default: Component; }>; /** * ComponentType — the full union of everything that can be passed as a * view / component reference. Use this when you need to accept both eager * and lazy forms in a single parameter type. */ export type ComponentType = Record> = Component | LazyComponent; /** * Setter — wraps an event handler so it runs in the context of the * current host component. */ export type Setter = any>(fn: T) => T; //# sourceMappingURL=x-x.types.d.ts.map