Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 69b8074

Browse files
committed
feat(sfc-playground): display vapor status
1 parent 1f134ae commit 69b8074

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

packages/sfc-playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"vite": "^5.0.5"
1414
},
1515
"dependencies": {
16-
"@vue/repl": "4.0.0-alpha.0",
16+
"@vue/repl": "4.0.0-alpha.1",
1717
"file-saver": "^2.0.5",
1818
"jszip": "^3.10.1",
1919
"vue": "workspace:*"

packages/sfc-playground/src/App.vue

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {
88
mergeImportMap,
99
File,
1010
StoreState,
11+
ImportMap,
1112
} from '@vue/repl'
1213
import type Monaco from '@vue/repl/monaco-editor'
1314
import type CodeMirror from '@vue/repl/codemirror-editor'
1415
import { ref, watchEffect, onMounted, computed, shallowRef, watch } from 'vue'
16+
import welcomeSFC from './welcome.vue?raw'
1517
1618
const EditorComponent = shallowRef<typeof Monaco | typeof CodeMirror>()
1719
@@ -52,15 +54,20 @@ const {
5254
: `${location.origin}/src/vue-server-renderer-dev-proxy`,
5355
})
5456
55-
const importMap = computed(() =>
56-
mergeImportMap(vueImportMap.value, {
57+
const importMap = computed(() => {
58+
const vapor = import.meta.env.PROD
59+
? `${location.origin}/vue-vapor.esm-browser.js`
60+
: `${location.origin}/src/vue-vapor-dev-proxy`
61+
62+
const vaporImportMap: ImportMap = {
5763
imports: {
58-
'vue/vapor': import.meta.env.PROD
59-
? `${location.origin}/vue-vapor.esm-browser.js`
60-
: `${location.origin}/src/vue-vapor-dev-proxy`,
64+
'vue/vapor': vapor,
6165
},
62-
}),
63-
)
66+
}
67+
if (useVaporMode.value) vaporImportMap.imports!.vue = vapor
68+
69+
return mergeImportMap(vueImportMap.value, vaporImportMap)
70+
})
6471
6572
let hash = location.hash.slice(1)
6673
if (hash.startsWith('__DEV__')) {
@@ -81,7 +88,6 @@ if (hash.startsWith('__VAPOR__')) {
8188
}
8289
8390
const files: StoreState['files'] = ref(Object.create(null))
84-
const mainFile = ref('src/App.vue')
8591
8692
// enable experimental features
8793
const sfcOptions = computed(
@@ -110,7 +116,9 @@ const store = useStore(
110116
vueVersion,
111117
builtinImportMap: importMap,
112118
sfcOptions,
113-
mainFile,
119+
template: ref({
120+
welcomeSFC: welcomeSFC,
121+
}),
114122
},
115123
hash,
116124
)
@@ -132,11 +140,13 @@ watch(
132140
`<div id="app"></div>`,
133141
true,
134142
)
135-
mainFile.value = 'src/index.html'
136-
store.activeFile = files.value['src/App.vue']
143+
store.mainFile = 'src/index.html'
137144
} else if (files.value['src/index.html']?.hidden) {
138145
delete files.value['src/index.html']
139-
mainFile.value = 'src/App.vue'
146+
store.mainFile = 'src/App.vue'
147+
if (store.activeFile.filename === 'src/index.html') {
148+
store.activeFile = files.value['src/App.vue']
149+
}
140150
}
141151
},
142152
{ immediate: true },
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup>
2+
import { ref, getCurrentInstance } from 'vue'
3+
4+
const msg = ref('Hello World!')
5+
const isVapor = getCurrentInstance().vapor
6+
</script>
7+
8+
<template>
9+
<h1>{{ msg }}</h1>
10+
<input v-model="msg" />
11+
<b>VAPOR {{ isVapor ? 'ON' : 'OFF' }}</b>
12+
</template>

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)