Skip to content

Commit 13963f7

Browse files
committed
feat: add changes in upstream 3.1.0
2 parents facd616 + 63cbc45 commit 13963f7

File tree

6 files changed

+50
-94
lines changed

6 files changed

+50
-94
lines changed

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@pdanpdan/vue-repl",
33
"version": "1.0.15",
44
"description": "Vue component for editing Vue components",
5-
"packageManager": "pnpm@8.11.0",
5+
"packageManager": "pnpm@8.12.1",
66
"type": "module",
77
"main": "dist/ssr-stub.js",
88
"module": "dist/vue-repl.js",
@@ -91,17 +91,14 @@
9191
"bumpp": "^9.2.1",
9292
"codemirror": "^5.65.16",
9393
"conventional-changelog-cli": "^4.1.0",
94-
"emmet-monaco-es": "^5.3.0",
9594
"fflate": "^0.8.1",
9695
"hash-sum": "^2.0.0",
9796
"lint-staged": "^15.2.0",
9897
"monaco-editor-core": "^0.45.0",
99-
"monaco-editor-textmate": "^4.0.0",
100-
"monaco-textmate": "^3.0.1",
101-
"monaco-volar": "^0.4.0",
102-
"onigasm": "^2.2.5",
10398
"prettier": "^3.1.1",
10499
"simple-git-hooks": "^2.9.0",
100+
"shikiji": "^0.9.10",
101+
"shikiji-monaco": "^0.9.10",
105102
"sucrase": "^3.34.0",
106103
"typescript": "^5.3.3",
107104
"vite": "^5.0.10",

pnpm-lock.yaml

Lines changed: 22 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/monaco/Monaco.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
import * as monaco from 'monaco-editor-core'
1414
import { initMonaco } from './env'
1515
import { getOrCreateModel } from './utils'
16-
import { loadGrammars, loadTheme } from 'monaco-volar'
1716
import type { Store } from '../store'
1817
import type { EditorProps, EditorEmits } from '../editor/types'
1918
@@ -35,7 +34,7 @@ const lang = computed(() => (props.mode === 'css' ? 'css' : 'javascript'))
3534
let editorInstanceMounted = false
3635
3736
onMounted(async () => {
38-
const theme = await loadTheme(monaco.editor)
37+
const theme = await import('./highlight').then(r => r.registerHighlighter())
3938
ready.value = true
4039
await nextTick()
4140
@@ -59,7 +58,6 @@ onMounted(async () => {
5958
inlineSuggest: {
6059
enabled: false,
6160
},
62-
'semanticHighlighting.enabled': true,
6361
fixedOverflowWidgets: true,
6462
})
6563
editor.value = editorInstance
@@ -166,8 +164,6 @@ onMounted(async () => {
166164
emit('change', editorInstance.getValue(), props.filename)
167165
})
168166
}
169-
170-
await loadGrammars(monaco, editorInstance)
171167
})
172168
173169
onBeforeUnmount(() => {

src/monaco/env.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import * as volar from '@volar/monaco'
33
import * as monaco from 'monaco-editor-core'
44
import { editor, languages, Uri } from 'monaco-editor-core'
55
import editorWorker from 'monaco-editor-core/esm/vs/editor/editor.worker?worker'
6-
import { emmetHTML } from 'emmet-monaco-es'
7-
import * as onigasm from 'onigasm'
8-
import onigasmWasm from 'onigasm/lib/onigasm.wasm?url'
6+
97
import { watchEffect } from 'vue'
108
import { Store } from '../store'
119
import { getOrCreateModel } from './utils'
@@ -16,8 +14,6 @@ let initted = false
1614
export function initMonaco(store: Store) {
1715
if (initted) return
1816
loadMonacoEnv(store)
19-
loadWasm()
20-
emmetHTML(monaco as any, ['vue', 'html'])
2117

2218
watchEffect(() => {
2319
// create a model for each file in the store
@@ -65,10 +61,6 @@ export function initMonaco(store: Store) {
6561
initted = true
6662
}
6763

68-
export function loadWasm() {
69-
return onigasm.loadWASM(onigasmWasm)
70-
}
71-
7264
export class WorkerHost {
7365
onFetchCdnFile(uri: string, text: string) {
7466
;(

src/monaco/highlight.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as monaco from 'monaco-editor-core'
2+
import { getHighlighterCore } from 'shikiji/core'
3+
import { getWasmInlined } from 'shikiji/wasm'
4+
import { shikijiToMonaco } from 'shikiji-monaco'
5+
6+
import langVue from 'shikiji/langs/vue.mjs'
7+
import themeDark from 'shikiji/themes/dark-plus.mjs'
8+
import themeLight from 'shikiji/themes/light-plus.mjs'
9+
10+
11+
export async function registerHighlighter() {
12+
const highlighter = await getHighlighterCore({
13+
themes: [themeDark, themeLight],
14+
langs: [langVue],
15+
loadWasm: getWasmInlined
16+
})
17+
monaco.languages.register({ id: 'vue' })
18+
shikijiToMonaco(highlighter, monaco)
19+
return {
20+
light: themeLight.name!,
21+
dark: themeDark.name!
22+
}
23+
}

vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export default mergeConfig(base, {
5151
optimizeDeps: {
5252
// avoid late discovered deps
5353
include: [
54-
'onigasm',
5554
'monaco-editor-core/esm/vs/editor/editor.worker',
5655
'vue/server-renderer',
5756
],

0 commit comments

Comments
 (0)