import "./tags-html"; declare module "*.marko" { const template: Marko.Template; export default template; } declare global { namespace NodeJS { interface ReadableStream {} } namespace Marko { /** A mutable global object for the current render. */ export interface Global { [x: PropertyKey]: unknown; /** An AbortSignal instance that, when aborted, stops further streamed content. */ signal?: AbortSignal; /** A CSP Nonce to add to each script output from Marko. */ cspNonce?: string; /** Used for rendering multiple Marko templates in a single hydrated page. */ renderId?: string; /** Used to uniquely identify a instance of a Marko runtime. */ runtimeId?: string; /** A list of globals that should be serialized to the browser. */ serializedGlobals?: string[] | Record; } export type TemplateInput = Input & { /** Data available within all rendered templates as `$global`. */ $global?: Global; }; /** The result of calling `template.render`. */ export type RenderedTemplate = Promise & AsyncIterable & { toReadable(): ReadableStream>; pipe(stream: { write(chunk: string): unknown; end(): unknown; flush?(): void; }): void; toString(): string; }; /** The result of calling `template.mount`. */ export type MountedTemplate = { get value(): Return extends { value: infer Value } ? Value : void; set value( next: Return extends { valueChange?(next: infer Next): any } ? Next : never, ); update(input: Marko.TemplateInput): void; destroy(): void; }; /** Body content created by a template. */ export interface Body< in Params extends readonly any[] = [], out Return = void, > {} /** Valid data types which can be passed in as a <${dynamic}/> tag name. */ export type Renderable = | { content: Body | Template | string } | Body | Template | string; /** Extract the return tag type from body content. */ export type BodyReturnType = B extends Body ? Return : never; /** Extract the tag parameter types received by body content. */ export type BodyParameters = B extends Body ? Params : never; /** The top level api for a Marko Template. */ export abstract class Template { /** * The following types are processed up by the @marko/language-tools * and inlined into the compiled template. * * This is done to support generics on each of these methods * until TypeScript supports higher kinded types. * * https://github.com/microsoft/TypeScript/issues/1213 */ /** @marko-overload-start */ /** Render the template to a string. */ abstract render( input: Marko.TemplateInput, ): Marko.RenderedTemplate; /** Render and attach the template to a DOM node. */ abstract mount( input: Marko.TemplateInput, reference: Node, position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend", ): Marko.MountedTemplate; /** @marko-overload-end */ } export type AttrTag = T & { [Symbol.iterator](): Iterator; }; export interface NativeTag< Input extends Record, Return extends Element, > { input: Input; return: { value: () => Return }; } export interface NativeTags { [name: string]: NativeTag, Element>; } export type Input = 0 extends 1 & Name ? any : Name extends string ? Name extends keyof NativeTags ? NativeTags[Name]["input"] : Record : Name extends | Template | { _(): () => (input: infer Input) => any } ? Input : Name extends Body ? Args extends { length: infer Length; } ? number extends Length ? Args[0] | undefined : 0 extends Length ? undefined : Args[0] : never : never; export type Return = 0 extends 1 & Name ? any : Name extends string ? Name extends keyof NativeTags ? NativeTags[Name]["return"] : () => Element : Name extends | { _(): () => (input: any) => { return: infer Return } } | Template | Body ? Return : never; } }