wxt
Version:
⚡ Next-gen Web Extension Framework
41 lines (40 loc) • 1.76 kB
text/typescript
import { ContentScriptContext } from "../content-script-context.mjs";
import { ContentScriptUi, ContentScriptUiOptions } from "./types.mjs";
import * as _$wxt_browser0 from "wxt/browser";
//#region src/utils/content-script-ui/iframe.d.ts
/**
* Create a content script UI using an iframe.
*
* @see https://wxt.dev/guide/essentials/content-scripts.html#iframe
*/
declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: IframeContentScriptUiOptions<TMounted>): IframeContentScriptUi<TMounted>;
interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
/** The iframe added to the DOM. */
iframe: HTMLIFrameElement;
/** A wrapper div that assists in positioning. */
wrapper: HTMLDivElement;
}
type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
/**
* The path to the HTML page that will be shown in the iframe. This string
* is passed into `browser.runtime.getURL`.
*/
page: _$wxt_browser0.HtmlPublicPath;
/**
* Callback executed when mounting the UI. Use this function to customize
* the iframe or wrapper element's appearance. It is called every time
* `ui.mount()` is called.
*
* Optionally return a value that can be accessed at `ui.mounted` or in the
* `onRemove` callback.
*/
onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
/**
* Callback executed before mounting the UI. Use this function to customize
* the iframe or wrapper elements before they are injected into the DOM. It
* is called every time `ui.mount()` is called.
*/
onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void;
};
//#endregion
export { IframeContentScriptUi, IframeContentScriptUiOptions, createIframeUi };