import { Thread, type ThreadMessageTarget } from '../../Thread.ts'; import type { ThreadWindowOptions } from './ThreadWindow.ts'; /** * Creates a thread from within a window created by a parent document (for example, * an `iframe` or popup window). * * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener * * @example * import {ThreadNestedWindow} from '@quilted/threads'; * * // Inside a document opened as a popup window * const thread = new ThreadNestedWindow(window.opener); * await thread.imports.sendMessage('Hello world!'); */ export declare class ThreadNestedWindow, Exports = Record> extends Thread { readonly parent: Window; /** * Creates a thread from within a window created by a parent document (for example, * an `iframe` or popup window). * * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener * * @example * import {ThreadNestedWindow} from '@quilted/threads'; * * // Inside a document opened as a popup window * const thread = ThreadNestedWindow.from(window.opener); * await thread.imports.sendMessage('Hello world!'); */ static from, Exports = Record>(window: Window, options?: ThreadWindowOptions): ThreadNestedWindow; /** * Starts a thread wrapped around a nested `window` object, and returns the imports * of the thread. * * @example * ```ts * import {ThreadNestedWindow} from '@quilted/threads'; * * const {getMessage} = ThreadNestedWindow.import(window.opener); * const message = await getMessage(); // 'Hello, world!' * * // In the parent window: * * import {ThreadWindow} from '@quilted/threads'; * * ThreadWindow.export(window, { * async getMessage() { * return 'Hello, world!'; * }, * }); * ``` */ static import>(window: Window, options?: Omit>, 'imports'>): import("../../Thread.ts").ThreadImports; /** * Starts a thread wrapped around a nested `window` object, providing the second * argument as the exports of the thread. * * @example * ```ts * import {ThreadNestedWindow} from '@quilted/threads'; * * ThreadNestedWindow.export(window.opener, { * async getMessage() { * return 'Hello, world!'; * }, * }); * * // In the parent window: * * import {ThreadWindow} from '@quilted/threads'; * * const {getMessage} = ThreadWindow.import(window); * const message = await getMessage(); // 'Hello, world!' * ``` */ static export>(window: Window, exports: Exports, options?: Omit, Exports>, 'exports'>): void; constructor(parent: Window, { targetOrigin, ...options }?: ThreadWindowOptions); } export declare function nestedWindowToThreadTarget(parent: Window, { targetOrigin }?: { targetOrigin?: string; }): ThreadMessageTarget; //# sourceMappingURL=ThreadNestedWindow.d.ts.map