fix: add error listeners + WASM test page
This commit is contained in:
@@ -31,6 +31,14 @@ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.addEventListener('error', function(e) {
|
||||
document.getElementById('content').innerHTML = '<p style="color:red">Global error: ' + e.message + '</p>';
|
||||
});
|
||||
window.addEventListener('unhandledrejection', function(e) {
|
||||
document.getElementById('content').innerHTML = '<p style="color:red">Unhandled: ' + e.reason + '</p>';
|
||||
});
|
||||
</script>
|
||||
<script src="/doc-wasm/pkg/md_wasm.js"></script>
|
||||
<div id="app">
|
||||
<div class="sidebar">
|
||||
|
||||
29
docs_v1.0/doc_wasm/test_wasm.html
Normal file
29
docs_v1.0/doc_wasm/test_wasm.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>WASM Test</title></head>
|
||||
<body>
|
||||
<h1>WASM Render Test</h1>
|
||||
<div id="output">Loading...</div>
|
||||
<div id="output2"></div>
|
||||
<script src="/doc-wasm/pkg/md_wasm.js"></script>
|
||||
<script>
|
||||
async function test() {
|
||||
const out = document.getElementById('output');
|
||||
try {
|
||||
out.textContent = 'Calling wasm_bindgen...';
|
||||
const wasm = await wasm_bindgen();
|
||||
out.textContent = 'WASM loaded, testing render...';
|
||||
|
||||
const html = wasm.render('# Hello\nThis is **markdown**');
|
||||
out.innerHTML = html;
|
||||
|
||||
document.getElementById('output2').textContent = 'Render worked! Length: ' + html.length;
|
||||
} catch(e) {
|
||||
out.innerHTML = '<p style="color:red">Error: ' + e.message + '</p>';
|
||||
document.getElementById('output2').textContent = e.stack;
|
||||
}
|
||||
}
|
||||
test();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user