Skip to content

Commit

Permalink
feat: expose loading status
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 10, 2024
1 parent 08b4492 commit eee6bb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/store.ts
Expand Up @@ -51,6 +51,8 @@ export function useStore(
}: Partial<StoreState> = {},
serializedState?: string,
): ReplStore {
const loading = ref(false)

function applyBuiltinImportMap() {
const importMap = mergeImportMap(builtinImportMap.value, getImportMap())
setImportMap(importMap)
Expand Down Expand Up @@ -86,7 +88,10 @@ export function useStore(
watch(vueVersion, async (version) => {
if (version) {
const compilerUrl = `https://cdn.jsdelivr.net/npm/@vue/compiler-sfc@${version}/dist/compiler-sfc.esm-browser.js`
compiler.value = await import(/* @vite-ignore */ compilerUrl)
loading.value = true
compiler.value = await import(/* @vite-ignore */ compilerUrl).finally(
() => (loading.value = false),
)
console.info(`[@vue/repl] Now using Vue version: ${version}`)
} else {
// reset to default
Expand Down Expand Up @@ -329,6 +334,7 @@ export function useStore(
outputMode,
sfcOptions,
compiler,
loading,
vueVersion,

locale,
Expand Down Expand Up @@ -402,6 +408,8 @@ export type StoreState = ToRefs<{

export interface ReplStore extends UnwrapRef<StoreState> {
activeFile: File
/** Loading compiler */
loading: boolean
init(): void
setActive(filename: string): void
addFile(filename: string | File): void
Expand Down

0 comments on commit eee6bb3

Please sign in to comment.