import { Row, Button, Column, Node } from "./domlink.ts"; // extra little handy things i guess. export async function timeout(time: number, promise: Promise): Promise { const result = await Promise.race([new Promise(r=>setTimeout(r, time, null)), promise]); if (result == null) { throw new Error("timeout"); } return result; } function webFrame(url: string) { const frame = document.createElement("iframe"); frame.src = url; frame.style.width = "100%"; frame.style.height = "100%"; const controls = new Row().with( "Web Frame Controls:", new Button("reload", ()=>{frame.contentWindow?.location.reload();}) ); return new Column().with( controls, new Node(frame) ).style((s)=>{ s.width = "100%"; s.height = "100%"; }); }