in src/js-executor/index.js [96:124]
async execute(jsCode, jsLibs, theme, onError, platform) {
const loadedScripts = (
this.iframe.contentDocument || this.iframe.document
).getElementsByTagName('script').length;
let offset;
if (platform === TargetPlatforms.JS_IR) {
// 1 scripts by default: INIT_SCRIPT_IR
offset = 1;
} else {
// 2 scripts by default: INIT_SCRIPT + kotlin stdlib
offset = 2;
}
if (loadedScripts === jsLibs.size + offset) {
try {
const output = this.iframe.contentWindow.eval(jsCode);
return output
? `<span class="standard-output ${theme}">${processingHtmlBrackets(
output,
)}</span>`
: '';
} catch (e) {
if (onError) onError();
let exceptionOutput = showJsException(e);
return `<span class="error-output">${exceptionOutput}</span>`;
}
}
await this.timeout(400);
return await this.execute(jsCode, jsLibs, theme, onError, platform);
}