|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
import init, { evaluateProject, formatSource } from 'decodal-wasm';
|
|
|
|
|
import init, { evaluateProject } from 'decodal-wasm';
|
|
|
|
|
import { EditorView, basicSetup } from 'codemirror';
|
|
|
|
|
import { keymap } from '@codemirror/view';
|
|
|
|
|
import { decodal } from 'decodal-codemirror';
|
|
|
|
@@ -10,7 +10,6 @@ const starterProject = playgroundExamples[0];
|
|
|
|
|
const editorHost = document.getElementById('editor');
|
|
|
|
|
const output = document.getElementById('output');
|
|
|
|
|
const run = document.getElementById('run');
|
|
|
|
|
const formatButton = document.getElementById('format');
|
|
|
|
|
const status = document.getElementById('status');
|
|
|
|
|
const fileTree = document.getElementById('file-tree');
|
|
|
|
|
const activeFile = document.getElementById('active-file');
|
|
|
|
@@ -177,20 +176,6 @@ function execute() {
|
|
|
|
|
output.classList.toggle('error', !result.ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatActiveFile() {
|
|
|
|
|
const result = JSON.parse(formatSource(getEditorText()));
|
|
|
|
|
if (!result.ok) {
|
|
|
|
|
output.textContent = result.error;
|
|
|
|
|
output.classList.add('error');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setEditorText(result.source);
|
|
|
|
|
project.files[project.activePath] = result.source;
|
|
|
|
|
saveProject();
|
|
|
|
|
output.textContent = 'Formatted.';
|
|
|
|
|
output.classList.remove('error');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFileTree() {
|
|
|
|
|
const tree = buildTree(Object.keys(project.files).sort());
|
|
|
|
|
fileTree.replaceChildren(renderTreeList(tree.children));
|
|
|
|
@@ -244,7 +229,6 @@ function compareNodes(a, b) {
|
|
|
|
|
try {
|
|
|
|
|
await init();
|
|
|
|
|
run.disabled = false;
|
|
|
|
|
formatButton.disabled = false;
|
|
|
|
|
status.textContent = '';
|
|
|
|
|
execute();
|
|
|
|
|
} catch (error) {
|
|
|
|
@@ -252,7 +236,6 @@ try {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run.addEventListener('click', execute);
|
|
|
|
|
formatButton.addEventListener('click', formatActiveFile);
|
|
|
|
|
loadExample.addEventListener('click', () => {
|
|
|
|
|
const example = playgroundExamples.find((item) => item.id === exampleSelect.value);
|
|
|
|
|
if (!example) return;
|
|
|
|
|