hello.js
Код: Выделить всё
import { WebContainer } from 'https://cdn.jsdelivr.net/npm/@webcontainer/api/dist/index.js';
let wc;
document.addEventListener('DOMContentLoaded', async () => {
const out = document.getElementById('out');
const codeEl = document.getElementById('code-editor');
wc = await WebContainer.boot({ coep: 'require-corp' });
const runner = new Worker('./run-worker.js', { type: 'module' });
runner.onmessage = (m) => {
const { stdout, stderr, exitCode } = m.data || {};
out.textContent += stdout + (stderr ? '\n[stderr]\n' + stderr : '') + '\n[exit ' + exitCode + ']';
};
document.getElementById('run').onclick = async () => {
try {
out.textContent = 'Compiling...\n';
const code = codeEl.value || '#include \nint main(){std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79826085/is-it-possible-to-compile-c-that-user-types-to-wasm-client-side-using-web-cont[/url]
Мобильная версия