js-slang
Version:
Javascript-based implementations of Source, written in Typescript
19 lines • 809 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.htmlRunner = exports.htmlErrorHandlingScript = void 0;
const HTML_ERROR_HANDLING_SCRIPT_TEMPLATE = `<script>
window.onerror = (msg, url, lineNum) => {
window.parent.postMessage("Line " + Math.max(lineNum - %d, 0) + ": " + msg, "*");
};
</script>\n`;
const errorScriptLines = HTML_ERROR_HANDLING_SCRIPT_TEMPLATE.split('\n').length - 1;
exports.htmlErrorHandlingScript = HTML_ERROR_HANDLING_SCRIPT_TEMPLATE.replace('%d', errorScriptLines.toString());
async function htmlRunner(code, context, _options = {}) {
return Promise.resolve({
status: 'finished',
context,
value: exports.htmlErrorHandlingScript + code
});
}
exports.htmlRunner = htmlRunner;
//# sourceMappingURL=htmlRunner.js.map
;