Skip to content

Commit eee6bb3

Browse files
committed
feat: expose loading status
1 parent 08b4492 commit eee6bb3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/store.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export function useStore(
5151
}: Partial<StoreState> = {},
5252
serializedState?: string,
5353
): ReplStore {
54+
const loading = ref(false)
55+
5456
function applyBuiltinImportMap() {
5557
const importMap = mergeImportMap(builtinImportMap.value, getImportMap())
5658
setImportMap(importMap)
@@ -86,7 +88,10 @@ export function useStore(
8688
watch(vueVersion, async (version) => {
8789
if (version) {
8890
const compilerUrl = `https://cdn.jsdelivr.net/npm/@vue/compiler-sfc@${version}/dist/compiler-sfc.esm-browser.js`
89-
compiler.value = await import(/* @vite-ignore */ compilerUrl)
91+
loading.value = true
92+
compiler.value = await import(/* @vite-ignore */ compilerUrl).finally(
93+
() => (loading.value = false),
94+
)
9095
console.info(`[@vue/repl] Now using Vue version: ${version}`)
9196
} else {
9297
// reset to default
@@ -329,6 +334,7 @@ export function useStore(
329334
outputMode,
330335
sfcOptions,
331336
compiler,
337+
loading,
332338
vueVersion,
333339

334340
locale,
@@ -402,6 +408,8 @@ export type StoreState = ToRefs<{
402408

403409
export interface ReplStore extends UnwrapRef<StoreState> {
404410
activeFile: File
411+
/** Loading compiler */
412+
loading: boolean
405413
init(): void
406414
setActive(filename: string): void
407415
addFile(filename: string | File): void

0 commit comments

Comments
 (0)