Skip to content

Commit 124160e

Browse files
authored
workflow: upgrade repl, use monaco + volar for sfc playground (#8625)
1 parent ae7453f commit 124160e

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

packages/sfc-playground/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
<title>Vue SFC Playground</title>
99
<script>
1010
// process shim for old versions of @vue/compiler-sfc dependency
11-
window.process = { env: {} }
12-
const savedPreferDark = localStorage.getItem('vue-sfc-playground-prefer-dark')
13-
if (
14-
savedPreferDark === 'true' ||
15-
(!savedPreferDark && window.matchMedia('(prefers-color-scheme: dark)').matches)
16-
) {
11+
// window.process = { env: {} }
12+
// const savedPreferDark = localStorage.getItem('vue-sfc-playground-prefer-dark')
13+
// if (
14+
// savedPreferDark === 'true' ||
15+
// (!savedPreferDark && window.matchMedia('(prefers-color-scheme: dark)').matches)
16+
// ) {
1717
document.documentElement.classList.add('dark')
18-
}
18+
// }
1919
</script>
2020
<script type="module" src="/src/main.ts"></script>
2121
</head>

packages/sfc-playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"vite": "^4.3.0"
1313
},
1414
"dependencies": {
15-
"@vue/repl": "^1.5.0",
15+
"@vue/repl": "^2.1.3",
1616
"file-saver": "^2.0.5",
1717
"jszip": "^3.6.0",
1818
"vue": "workspace:*"

packages/sfc-playground/src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import Header from './Header.vue'
33
import { Repl, ReplStore, SFCOptions } from '@vue/repl'
4+
import Monaco from '@vue/repl/monaco-editor'
45
import { ref, watchEffect } from 'vue'
56
67
const setVH = () => {
@@ -82,6 +83,7 @@ function toggleSSR() {
8283
@toggle-ssr="toggleSSR"
8384
/>
8485
<Repl
86+
:editor="Monaco"
8587
@keydown.ctrl.s.prevent
8688
@keydown.meta.s.prevent
8789
:ssr="useSSRMode"

packages/sfc-playground/src/Header.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
import { downloadProject } from './download/download'
33
import { ref, onMounted } from 'vue'
4-
import Sun from './icons/Sun.vue'
5-
import Moon from './icons/Moon.vue'
4+
// import Sun from './icons/Sun.vue'
5+
// import Moon from './icons/Moon.vue'
66
import Share from './icons/Share.vue'
77
import Download from './icons/Download.vue'
88
import GitHub from './icons/GitHub.vue'
@@ -51,14 +51,14 @@ async function copyLink(e: MouseEvent) {
5151
alert('Sharable URL has been copied to clipboard.')
5252
}
5353
54-
function toggleDark() {
55-
const cls = document.documentElement.classList
56-
cls.toggle('dark')
57-
localStorage.setItem(
58-
'vue-sfc-playground-prefer-dark',
59-
String(cls.contains('dark'))
60-
)
61-
}
54+
// function toggleDark() {
55+
// const cls = document.documentElement.classList
56+
// cls.toggle('dark')
57+
// localStorage.setItem(
58+
// 'vue-sfc-playground-prefer-dark',
59+
// String(cls.contains('dark'))
60+
// )
61+
// }
6262
6363
onMounted(async () => {
6464
window.addEventListener('click', () => {
@@ -145,10 +145,10 @@ async function fetchVersions(): Promise<string[]> {
145145
>
146146
<span>{{ ssr ? 'SSR ON' : 'SSR OFF' }}</span>
147147
</button>
148-
<button title="Toggle dark mode" class="toggle-dark" @click="toggleDark">
148+
<!-- <button title="Toggle dark mode" class="toggle-dark" @click="toggleDark">
149149
<Sun class="light" />
150150
<Moon class="dark" />
151-
</button>
151+
</button> -->
152152
<button title="Copy sharable URL" class="share" @click="copyLink">
153153
<Share />
154154
</button>

packages/sfc-playground/src/download/download.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ export async function downloadProject(store: ReplStore) {
2727

2828
const files = store.getFiles()
2929
for (const file in files) {
30-
src.file(file, files[file])
30+
if (file !== 'import-map.json') {
31+
src.file(file, files[file])
32+
} else {
33+
zip.file(file, files[file])
34+
}
3135
}
3236

3337
const blob = await zip.generateAsync({ type: 'blob' })

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)