import * as monaco from 'monaco-editor'; import { watchEffect } from 'vue'; import { transform } from '@babel/standalone'; import babelPluginJsx from '@vue/babel-plugin-jsx'; // @ts-expect-error missing types import typescript from '@babel/plugin-syntax-typescript'; import { type VueJSXPluginOptions, compilerOptions, initOptions, } from './options'; import './editor.worker'; import './index.css'; main(); interface PersistedState { src: string; options: VueJSXPluginOptions; } function main() { const persistedState: PersistedState = JSON.parse( localStorage.getItem('state') || '{}' ); Object.assign(compilerOptions, persistedState.options); const sharedEditorOptions: monaco.editor.IStandaloneEditorConstructionOptions = { language: 'typescript', tabSize: 2, theme: 'vs-dark', fontSize: 14, wordWrap: 'on', scrollBeyondLastLine: false, renderWhitespace: 'selection', contextmenu: false, minimap: { enabled: false, }, }; monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({ noSemanticValidation: true, }); monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ allowJs: true, allowNonTsExtensions: true, jsx: monaco.languages.typescript.JsxEmit.Preserve, target: monaco.languages.typescript.ScriptTarget.Latest, module: monaco.languages.typescript.ModuleKind.ESNext, isolatedModules: true, }); const editor = monaco.editor.create(document.getElementById('source')!, { ...sharedEditorOptions, model: monaco.editor.createModel( decodeURIComponent(window.location.hash.slice(1)) || persistedState.src || `import { defineComponent } from 'vue' const App = defineComponent((props) =>