Multiple copies of the emulator on a page

This commit is contained in:
2023-01-28 22:29:37 -06:00
parent c825e6d727
commit 7e969f1469
4 changed files with 57 additions and 16 deletions
+8 -13
View File
@@ -1,17 +1,12 @@
import { createRoot } from 'react-dom/client'
import React from "react";
import SnippetEmulator from "./snippet_emulator";
import React from 'react'
import SnippetEmulator from './snippet_emulator'
import init, { WasmCPU, assemble_snippet } from '../pkg/vweb.js'
init().then(async () => {
createRoot(document.getElementsByClassName('react-root')[0])
.render(
<SnippetEmulator>
{`.org 0x400
push 2
add 3
mul 4
hlt`}
</SnippetEmulator>
)
document.addEventListener('DOMContentLoaded', () => {
init().then(() => {
document.querySelectorAll('.snippet').forEach((el) => {
createRoot(el).render(React.createElement(SnippetEmulator, { children: el.innerText }))
})
})
})