Skip to content

Commit

Permalink
fix: use worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl committed Jun 13, 2022
1 parent f765d54 commit e1e80b9
Show file tree
Hide file tree
Showing 21 changed files with 1,104 additions and 850 deletions.
5 changes: 4 additions & 1 deletion index-dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
<script type="module">
import { createApp } from 'vue'
import { Repl } from './dist/vue-repl'
import Monaco from './dist/vue-repl-monaco-editor'
import './dist/style.css'
createApp(Repl).mount('#app')
createApp(Repl, {
editor: Monaco
}).mount('#app')
</script>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@vue/shared": "^3.2.37",
"codemirror": "^5.62.3",
"hash-sum": "^2.0.0",
"monaco-editor-core": "^0.33.0",
"rimraf": "^3.0.2",
"sucrase": "^3.20.1",
"typescript": "^4.7.3",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ provide('clear-console', toRef(props, 'clearConsole'))
<template #right>
<Output
:showCompileOutput="props.showCompileOutput"
:editor-component="editor"
:ssr="!!props.ssr"
/>
</template>
Expand Down
21 changes: 13 additions & 8 deletions src/monaco/Monaco.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script lang="ts">
import { setupMonacoEnv } from './utils';
import { setupMonacoEnv } from './env';
setupMonacoEnv();
import './monaco.contribution'
</script>
<script lang="ts" setup>
import { onMounted, onBeforeUnmount, ref, shallowRef, nextTick, watchEffect } from 'vue';
import { loadGrammars } from './grammars';
import * as monaco from 'monaco-editor';
import { setupThemePromise } from './utils';
import { setupLs, getOrCreateModel, setupValidate } from './ls';
import * as monaco from 'monaco-editor-core';
import { setupThemePromise, getOrCreateModel } from './utils';
// import { setupLs, setupValidate } from './ls';
const props = withDefaults(defineProps<{
value?: string
Expand Down Expand Up @@ -35,7 +36,9 @@ const currentModel = shallowRef<monaco.editor.ITextModel>(
)
)
const documentModelMap = shallowRef(new Map([[currentModel.value.uri.fsPath, currentModel.value]]))
// const documentModelMap = shallowRef(new Map([[
// currentModel.value.uri.fsPath, currentModel.value
// ]]))
watchEffect(() => {
if (currentModel.value.getValue() !== props.value) {
Expand Down Expand Up @@ -63,11 +66,11 @@ onMounted(async () => {
},
inlineSuggest: {
enabled: false,
},
}
});
editor.value = editorInstance
const ls = await setupLs(editorInstance, documentModelMap)
// const ls = await setupLs(editorInstance, documentModelMap)
await loadGrammars(editorInstance);
Expand All @@ -79,7 +82,9 @@ onMounted(async () => {
emits('change', editorInstance.getValue());
});
setupValidate(editorInstance, ls);
// setupValidate(editorInstance, ls);
});
onBeforeUnmount(() => {
Expand Down

0 comments on commit e1e80b9

Please sign in to comment.