Refactor: Use ES Module import in browser app

This commit is contained in:
2025-09-26 00:54:24 -07:00
parent 0dccd0a413
commit 67bf4c6777

31
browser/app.js Normal file
View File

@@ -0,0 +1,31 @@
import { hi2js } from '../transpiler.js';
document.addEventListener('DOMContentLoaded', () => {
const hiInput = document.getElementById('hi-input');
const jsOutput = document.getElementById('js-output');
const transpile = () => {
const hiCode = hiInput.value;
try {
const jsCode = hi2js(hiCode);
jsOutput.value = jsCode;
jsOutput.style.color = '#333';
} catch (e) {
jsOutput.value = `Error: ${e.message}`;
jsOutput.style.color = 'red';
}
};
hiInput.addEventListener('input', transpile);
hiInput.value = `// Welcome, Master.
message: "Hello from the browser!"
_(message)
// Try changing the value
count: 10
count = count + 5
_("The new count is", count)
`;
transpile();
});