@@ -8,10 +8,12 @@ import {
88 mergeImportMap ,
99 File ,
1010 StoreState ,
11+ ImportMap ,
1112} from ' @vue/repl'
1213import type Monaco from ' @vue/repl/monaco-editor'
1314import type CodeMirror from ' @vue/repl/codemirror-editor'
1415import { ref , watchEffect , onMounted , computed , shallowRef , watch } from ' vue'
16+ import welcomeSFC from ' ./welcome.vue?raw'
1517
1618const 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
6572let hash = location .hash .slice (1 )
6673if (hash .startsWith (' __DEV__' )) {
@@ -81,7 +88,6 @@ if (hash.startsWith('__VAPOR__')) {
8188}
8289
8390const files: StoreState [' files' ] = ref (Object .create (null ))
84- const mainFile = ref (' src/App.vue' )
8591
8692// enable experimental features
8793const 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 },
0 commit comments