From 3e45be1278871ddb5695c3e9fd1ca11d1839cf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Sun, 19 Jan 2025 11:30:18 +0800 Subject: [PATCH 1/8] fix: fix the ts version selected by the user --- src/store.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store.ts b/src/store.ts index 5ccf761c..6839bccb 100644 --- a/src/store.ts +++ b/src/store.ts @@ -266,6 +266,7 @@ export function useStore( } } if (vueVersion.value) files._version = vueVersion.value + if (typescriptVersion.value) files._tsVersion = typescriptVersion.value return '#' + utoa(JSON.stringify(files)) } const deserialize: ReplStore['deserialize'] = (serializedState: string) => { @@ -282,7 +283,10 @@ export function useStore( for (const filename in saved) { if (filename === '_version') { vueVersion.value = saved[filename] - } else { + } else if (filename === '_tsVersion') { + typescriptVersion.value = saved[filename] + } + else { setFile(files.value, filename, saved[filename]) } } From 56ad8a26b69ec7009666efcc8c8ca34a47173f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Tue, 18 Feb 2025 17:31:50 +0800 Subject: [PATCH 2/8] style: format code --- src/Repl.vue | 5 +++-- src/output/srcdoc.html | 5 +++-- src/store.ts | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Repl.vue b/src/Repl.vue index 66138ec7..038f0bac 100644 --- a/src/Repl.vue +++ b/src/Repl.vue @@ -127,8 +127,9 @@ defineExpose({ reload }) margin: 0; overflow: hidden; font-size: 13px; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, - Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; background-color: var(--bg-soft); } diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html index 189c19ca..5537714c 100644 --- a/src/output/srcdoc.html +++ b/src/output/srcdoc.html @@ -6,8 +6,9 @@ color-scheme: dark; } body { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } diff --git a/src/store.ts b/src/store.ts index 26231eb2..e0174c8f 100644 --- a/src/store.ts +++ b/src/store.ts @@ -292,8 +292,7 @@ export function useStore( vueVersion.value = saved[filename] } else if (filename === '_tsVersion') { typescriptVersion.value = saved[filename] - } - else { + } else { setFile(files.value, filename, saved[filename]) } } From b2591da8444522cf9745c6e26fd2c67927df5fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 09:10:42 +0800 Subject: [PATCH 3/8] style: format code recover --- src/Repl.vue | 5 ++--- src/output/srcdoc.html | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Repl.vue b/src/Repl.vue index 038f0bac..66138ec7 100644 --- a/src/Repl.vue +++ b/src/Repl.vue @@ -127,9 +127,8 @@ defineExpose({ reload }) margin: 0; overflow: hidden; font-size: 13px; - font-family: - -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, - Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, + Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; background-color: var(--bg-soft); } diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html index 5537714c..189c19ca 100644 --- a/src/output/srcdoc.html +++ b/src/output/srcdoc.html @@ -6,9 +6,8 @@ color-scheme: dark; } body { - font-family: - -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, - Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } From 1f1b81d2f61e793c27756e8c14e7c567a9e007e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 09:26:48 +0800 Subject: [PATCH 4/8] fix: ts version selected by the user --- src/store.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store.ts b/src/store.ts index e0174c8f..412da68d 100644 --- a/src/store.ts +++ b/src/store.ts @@ -45,7 +45,7 @@ export function useStore( vueVersion = ref(null), locale = ref(), - typescriptVersion = ref('latest'), + typescriptVersion = ref(null), dependencyVersion = ref(Object.create(null)), reloadLanguageTools = ref(), }: Partial = {}, @@ -434,7 +434,7 @@ export type StoreState = ToRefs<{ // volar-related locale: string | undefined - typescriptVersion: string + typescriptVersion: string | null /** \{ dependencyName: version \} */ dependencyVersion: Record reloadLanguageTools?: (() => void) | undefined From b93dd556b239f14865199f8b0c531abc3eca6b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 09:41:31 +0800 Subject: [PATCH 5/8] fix: ts version selected by the user --- src/monaco/vue.worker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monaco/vue.worker.ts b/src/monaco/vue.worker.ts index 0940cadb..e3b4d77c 100644 --- a/src/monaco/vue.worker.ts +++ b/src/monaco/vue.worker.ts @@ -101,7 +101,7 @@ self.onmessage = async (msg: MessageEvent) => { async function importTsFromCdn(tsVersion: string) { const _module = globalThis.module ;(globalThis as any).module = { exports: {} } - const tsUrl = `https://cdn.jsdelivr.net/npm/typescript@${tsVersion}/lib/typescript.js` + const tsUrl = `https://cdn.jsdelivr.net/npm/typescript@${tsVersion || 'latest'}/lib/typescript.js` await import(/* @vite-ignore */ tsUrl) const ts = globalThis.module.exports globalThis.module = _module From 9e686f052802add4738a9165e13280ee353a3290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 14:42:41 +0800 Subject: [PATCH 6/8] fix: ts version selected by the user --- src/store.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/store.ts b/src/store.ts index 412da68d..2508b679 100644 --- a/src/store.ts +++ b/src/store.ts @@ -45,7 +45,7 @@ export function useStore( vueVersion = ref(null), locale = ref(), - typescriptVersion = ref(null), + typescriptVersion = ref('latest'), dependencyVersion = ref(Object.create(null)), reloadLanguageTools = ref(), }: Partial = {}, @@ -270,7 +270,9 @@ export function useStore( } } if (vueVersion.value) files._version = vueVersion.value - if (typescriptVersion.value) files._tsVersion = typescriptVersion.value + if (typescriptVersion.value !== 'latest' || files._tsVersion) { + files._tsVersion = typescriptVersion.value + } return '#' + utoa(JSON.stringify(files)) } const deserialize: ReplStore['deserialize'] = ( @@ -434,7 +436,7 @@ export type StoreState = ToRefs<{ // volar-related locale: string | undefined - typescriptVersion: string | null + typescriptVersion: string /** \{ dependencyName: version \} */ dependencyVersion: Record reloadLanguageTools?: (() => void) | undefined From 0786e0085984fc0505c8d9d309157972fbd86622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 14:46:09 +0800 Subject: [PATCH 7/8] fix: ts version selected by the user --- src/monaco/vue.worker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/monaco/vue.worker.ts b/src/monaco/vue.worker.ts index e3b4d77c..024dc7eb 100644 --- a/src/monaco/vue.worker.ts +++ b/src/monaco/vue.worker.ts @@ -100,8 +100,8 @@ self.onmessage = async (msg: MessageEvent) => { async function importTsFromCdn(tsVersion: string) { const _module = globalThis.module - ;(globalThis as any).module = { exports: {} } - const tsUrl = `https://cdn.jsdelivr.net/npm/typescript@${tsVersion || 'latest'}/lib/typescript.js` + ; (globalThis as any).module = { exports: {} } + const tsUrl = `https://cdn.jsdelivr.net/npm/typescript@${tsVersion}/lib/typescript.js` await import(/* @vite-ignore */ tsUrl) const ts = globalThis.module.exports globalThis.module = _module From 331b60ee7f50ad5ebad2ec6b868b576d237e8023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=8E=E5=AF=8C?= <212149997@qq.com> Date: Wed, 19 Feb 2025 14:47:15 +0800 Subject: [PATCH 8/8] style: code format --- src/monaco/vue.worker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monaco/vue.worker.ts b/src/monaco/vue.worker.ts index 024dc7eb..0940cadb 100644 --- a/src/monaco/vue.worker.ts +++ b/src/monaco/vue.worker.ts @@ -100,7 +100,7 @@ self.onmessage = async (msg: MessageEvent) => { async function importTsFromCdn(tsVersion: string) { const _module = globalThis.module - ; (globalThis as any).module = { exports: {} } + ;(globalThis as any).module = { exports: {} } const tsUrl = `https://cdn.jsdelivr.net/npm/typescript@${tsVersion}/lib/typescript.js` await import(/* @vite-ignore */ tsUrl) const ts = globalThis.module.exports