import { Signal } from '@preact/signals-core'; export interface DocNode extends EventTarget { nodeType: number; cloneNode(includeChildren: boolean): DocNode; } export interface DocChildNode extends DocNode { nextSibling: DocChildNode | null; previousSibling: DocChildNode | null; parentNode: DocNode | null; } export interface DocComment extends DocChildNode { nodeValue: string | null; } export interface DocTextNode extends DocChildNode { nodeValue: string | null; } export interface DocParentNode extends DocNode { namespaceURI?: string; childNodes: ArrayLike; prepend(...nodes: (DocNode | string)[]): void; append(...nodes: (DocNode | string)[]): void; replaceChild(newNode: DocNode, oldNode: DocNode): void; } export interface DocElement extends DocParentNode, DocChildNode { namespaceURI: string; innerHTML: string; outerHTML: string; setAttribute(name: string, value: string): void; removeAttribute(name: string): void; } export interface DocHTMLElement extends DocElement { style: { cssText: string; setProperty(key: string, value: string): void; }; } export type Doc = { createComment: (text: string) => DocComment; createTextNode: (text: string) => DocTextNode; createDocumentFragment: () => DocParentNode; createElementNS(namespaceURI: 'http://www.w3.org/1999/xhtml' | 'http://www.w3.org/2000/svg' | 'http://www.w3.org/1998/Math/MathML' | null, qualifiedName: string, options?: undefined): DocElement; createElementNS(namespaceURI: string | null, qualifiedName: string, options?: undefined): DocElement; }; type hooks = never; export type ComponentProps = Record> = ExtraProps & { html: typeof html; children?: DocNode; context: (context: Context) => T | void; /** When streaming, an AbortSignal is passed so you can cancel work if the client disconnects */ signal?: AbortSignal; }; export type SyncChild = DocNode | string | SyncChild[] | false | null | undefined | Signal; export type PossiblyAsyncChild = SyncChild | PromiseLike; export type Component = Record> = (props: ComponentProps) => PossiblyAsyncChild; export type Context = Component & { __brand: 'Context'; __type: T; }; declare const createContext: () => Context; declare const Suspense: Component<{ fallback: SyncChild; children: PossiblyAsyncChild; }>; declare function html(strings: readonly string[], ...holes: unknown[]): DocNode; /** @ts-ignore **/ type GlobalDocument = typeof globalThis.document; type NativeDocument = typeof globalThis extends { document: any; } ? GlobalDocument : never; declare function render(component: Component>, doc?: [D | Doc, Function] | undefined): ReturnType['cloneNode']>; export { createContext, hooks as _h, render, Suspense };