import { bridgeScript } from "./bridge";
export const CODE_APP_SANDBOX = "allow-scripts";
export const CODE_APP_MAX_BYTES = 512 * 1024;
const POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'none'; img-src 'none'; font-src data:; media-src 'none'; object-src 'none'; frame-src 'none'; worker-src 'none'; base-uri 'none'; form-action 'none'";
const POLICY_META = ``;
export function checkCodeAppSize(html: string): void {
if (new TextEncoder().encode(html).byteLength > CODE_APP_MAX_BYTES) {
throw new RangeError("This App is too large to open.");
}
}
export function appDocument(html: string, css: string): string {
checkCodeAppSize(html);
// Escape stylesheet markup so the kit cannot close its host-owned style element.
const stylesheet = css.replace(/${POLICY_META}${html}`;
}