@casual-simulation/aux-vm-browser
Version:
A set of utilities required to securely run an AUX in a web browser.
54 lines • 2.23 kB
TypeScript
import '@casual-simulation/aux-vm/globalThis-polyfill';
import { Observable } from 'rxjs';
/**
* Creates a new message channel and sends port2 to the iframe in a message.
* @param iframeWindow The window to send the port to.
*/
export declare function setupChannel(iframeWindow: Window | Worker): MessageChannel;
/**
* Listens for the init_port event from the global context.
* @param origin The origin that the channels should be recieved from.
*/
export declare function listenForChannels(origin?: string): Observable<MessagePort>;
/**
* Listens for the init_port event from the global context.
* @param origin The origin that the channel should be recieved from.
*/
export declare function listenForChannel(origin?: string): Promise<MessagePort>;
export declare function waitForLoad(iframe: HTMLIFrameElement): Promise<void>;
/**
* Loads the script at the given URL into the given iframe window.
* @param iframeWindow The iframe.
* @param id The ID of the script.
* @param source The source code to load.
*/
export declare function loadScript(iframeWindow: Window, id: string, source: string): Promise<void>;
/**
* Injects the given message port with the given ID into the iframe.
* @param iframeWindow The iframe that the message port should be injected into.
* @param id The ID of the message port.
* @param port The port to inject.
*/
export declare function injectPort(iframeWindow: Window, id: string, port: MessagePort): Promise<void>;
/**
* Loads the script at the given URL into the given iframe window.
* @param iframeWindow The iframe.
* @param id The ID of the script.
* @param text The text to load.
* @param element The HTML element the text should be loaded in.
*/
export declare function loadText(iframeWindow: Window, id: string, text: string, element: string): Promise<void>;
/**
* Reloads the iframe.
* @param iframeWindow The iframe to reload.
*/
export declare function reload(iframeWindow: HTMLIFrameElement): Promise<void>;
/**
* Creates
* @param options
* @param properties
*/
export declare function setupCustomIframe(options: {
vmOrigin: string;
}, properties?: Partial<HTMLIFrameElement>): Promise<HTMLIFrameElement>;
//# sourceMappingURL=IFrameHelpers.d.ts.map