import { Thread } from '../Thread.ts'; import { type ThreadWindowOptions } from './window/ThreadWindow.ts'; import { ThreadNestedIframe } from './ThreadNestedIframe.ts'; /** * Creates a thread from an iframe element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe * * @example * import {ThreadIframe} from '@quilted/threads'; * * const iframe = document.querySelector('iframe#thread-iframe'); * const thread = new ThreadIframe(iframe); * await thread.imports.sendMessage('Hello world!'); */ export declare class ThreadIframe, Exports = Record> extends Thread { readonly iframe: HTMLIFrameElement; /** * Creates a thread from an iframe element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe * * @example * import {ThreadIframe} from '@quilted/threads'; * * const iframe = document.querySelector('iframe#thread-iframe'); * const thread = ThreadIframe.from(iframe); * await thread.imports.sendMessage('Hello world!'); */ static from, Exports = Record>(iframe: HTMLIFrameElement, options?: ThreadWindowOptions): ThreadIframe; /** * Starts a thread wrapped around an iframe element, and returns the imports * of the thread. * * @example * ```ts * import {ThreadIframe} from '@quilted/threads'; * * const {getMessage} = ThreadIframe.import(iframe); * const message = await getMessage(); // 'Hello, world!' * * // In the nested window: * * import {ThreadIframe} from '@quilted/threads'; * * ThreadIframe.parent.export({ * async getMessage() { * return 'Hello, world!'; * }, * }); * ``` */ static import>(iframe: HTMLIFrameElement, options?: Omit>, 'imports'>): import("../Thread.ts").ThreadImports>; /** * Starts a thread wrapped around an iframe element, providing the second * argument as the exports of the thread. * * @example * ```ts * import {ThreadIframe} from '@quilted/threads'; * * ThreadIframe.export(iframe, { * async getMessage() { * return 'Hello, world!'; * }, * }); * * // In the nested iframe: * * import {ThreadIframe} from '@quilted/threads'; * * const {getMessage} = ThreadIframe.parent.import(); * const message = await getMessage(); // 'Hello, world!' * ``` */ static export>(iframe: HTMLIFrameElement, exports: Exports, options?: Omit, Exports>, 'exports'>): void; /** * Creates a thread from a `window.parent`, a reference to the parent window when rendering * in a nested iframe. * * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/parent * * @example * import {ThreadIframe} from '@quilted/threads'; * * const thread = ThreadIframe.parent(); * await thread.imports.sendMessage('Hello world!'); */ static parent: (, Exports_1 = Record>(options?: ThreadWindowOptions) => ThreadNestedIframe) & { /** * Starts a thread wrapped around a parent window, and returns the imports * of the thread. * * @example * ```ts * import {ThreadIframe} from '@quilted/threads'; * * const {getMessage} = ThreadIframe.parent.import(); * const message = await getMessage(); // 'Hello, world!' * * // In the parent window: * * import {ThreadIframe} from '@quilted/threads'; * * ThreadIframe.export(iframe, { * async getMessage() { * return 'Hello, world!'; * }, * }); * ``` */ import: >(options?: Omit>, "imports">) => import("../Thread.ts").ThreadImports; /** * Starts a thread wrapped around a parent window, providing the second * argument as the exports of the thread. * * @example * ```ts * import {ThreadIframe} from '@quilted/threads'; * * ThreadIframe.parent.export({ * async getMessage() { * return 'Hello, world!'; * }, * }); * * // In the parent window: * * import {ThreadIframe} from '@quilted/threads'; * * const {getMessage} = ThreadIframe.import(iframe); * const message = await getMessage(); // 'Hello, world!' * ``` */ export: >(exports: Exports_1, options?: Omit, Exports_1>, "exports">) => void; }; constructor(iframe: HTMLIFrameElement, { targetOrigin, ...options }?: ThreadWindowOptions); } //# sourceMappingURL=ThreadIframe.d.ts.map