|
1 | 1 | import * as fs from 'node:fs'; |
2 | 2 | import * as path from 'node:path'; |
3 | | -import { computed, executeCommand, useAllExtensions, useVscodeContext, watchEffect } from 'reactive-vscode'; |
| 3 | +import { computed, useAllExtensions } from 'reactive-vscode'; |
4 | 4 | import * as semver from 'semver'; |
5 | 5 | import * as vscode from 'vscode'; |
6 | | -import { incompatibleExtensions, unknownExtensions } from './compatibility'; |
7 | | -import { config } from './config'; |
8 | | - |
9 | | -const extensions = useAllExtensions(); |
10 | | - |
11 | | -export const enabledHybridMode = computed(() => { |
12 | | - if (config.server.hybridMode === 'typeScriptPluginOnly') { |
13 | | - return false; |
14 | | - } |
15 | | - else if (config.server.hybridMode === 'auto') { |
16 | | - if ( |
17 | | - incompatibleExtensions.value.length || |
18 | | - unknownExtensions.value.length |
19 | | - ) { |
20 | | - return false; |
21 | | - } |
22 | | - else if ( |
23 | | - (vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) || |
24 | | - (workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0')) |
25 | | - ) { |
26 | | - return false; |
27 | | - } |
28 | | - return true; |
29 | | - } |
30 | | - return config.server.hybridMode; |
31 | | -}); |
32 | | - |
33 | | -export const enabledTypeScriptPlugin = computed(() => { |
34 | | - return ( |
35 | | - enabledHybridMode.value || |
36 | | - config.server.hybridMode === 'typeScriptPluginOnly' |
37 | | - ); |
38 | | -}); |
39 | 6 |
|
40 | 7 | const vscodeTsdkVersion = computed(() => { |
41 | 8 | const nightly = extensions.value.find( |
@@ -68,107 +35,33 @@ const workspaceTsdkVersion = computed(() => { |
68 | 35 | } |
69 | 36 | }); |
70 | 37 |
|
71 | | -export function useHybridModeTips() { |
72 | | - useVscodeContext('vueHybridMode', enabledHybridMode); |
| 38 | +const extensions = useAllExtensions(); |
73 | 39 |
|
74 | | - watchEffect(() => { |
75 | | - if (config.server.hybridMode === 'auto') { |
76 | | - if ( |
77 | | - incompatibleExtensions.value.length || |
78 | | - unknownExtensions.value.length |
79 | | - ) { |
80 | | - vscode.window |
81 | | - .showInformationMessage( |
82 | | - `Hybrid Mode is disabled automatically because there is a potentially incompatible ${[ |
83 | | - ...incompatibleExtensions.value, |
84 | | - ...unknownExtensions.value, |
85 | | - ].join(', ')} TypeScript plugin installed.`, |
86 | | - 'Open Settings', |
87 | | - 'Report a false positive' |
88 | | - ) |
89 | | - .then(value => { |
90 | | - if (value === 'Open Settings') { |
91 | | - executeCommand( |
92 | | - 'workbench.action.openSettings', |
93 | | - 'vue.server.hybridMode' |
94 | | - ); |
95 | | - } |
96 | | - else if (value == 'Report a false positive') { |
97 | | - vscode.env.openExternal( |
98 | | - vscode.Uri.parse( |
99 | | - 'https://github.com/vuejs/language-tools/pull/4206' |
100 | | - ) |
101 | | - ); |
102 | | - } |
103 | | - }); |
104 | | - } |
105 | | - else if ( |
106 | | - (vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) || |
107 | | - (workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0')) |
108 | | - ) { |
109 | | - let msg = `Hybrid Mode is disabled automatically because TSDK >= 5.3.0 is required (VSCode TSDK: ${vscodeTsdkVersion.value}`; |
110 | | - if (workspaceTsdkVersion.value) { |
111 | | - msg += `, Workspace TSDK: ${workspaceTsdkVersion.value}`; |
112 | | - } |
113 | | - msg += `).`; |
114 | | - vscode.window |
115 | | - .showInformationMessage(msg, 'Open Settings') |
116 | | - .then(value => { |
117 | | - if (value === 'Open Settings') { |
118 | | - executeCommand( |
119 | | - 'workbench.action.openSettings', |
120 | | - 'vue.server.hybridMode' |
121 | | - ); |
122 | | - } |
123 | | - }); |
124 | | - } |
| 40 | +export function checkCompatible() { |
| 41 | + for (const extension of extensions.value) { |
| 42 | + if ( |
| 43 | + extension.id === 'denoland.vscode-deno' |
| 44 | + && vscode.workspace.getConfiguration('deno').get<boolean>('enable') |
| 45 | + ) { |
| 46 | + vscode.window.showWarningMessage(`The ${extension.packageJSON.displayName}(${extension.id}) extension is incompatible with the Vue extension. Please disable Deno in workspace to avoid issues.`); |
125 | 47 | } |
126 | | - else if (config.server.hybridMode && incompatibleExtensions.value.length) { |
127 | | - vscode.window |
128 | | - .showWarningMessage( |
129 | | - `You have explicitly enabled Hybrid Mode, but you have installed known incompatible extensions: ${incompatibleExtensions.value.join( |
130 | | - ', ' |
131 | | - )}. You may want to change vue.server.hybridMode to "auto" to avoid compatibility issues.`, |
132 | | - 'Open Settings', |
133 | | - 'Report a false positive' |
134 | | - ) |
135 | | - .then(value => { |
136 | | - if (value === 'Open Settings') { |
137 | | - executeCommand( |
138 | | - 'workbench.action.openSettings', |
139 | | - 'vue.server.hybridMode' |
140 | | - ); |
141 | | - } |
142 | | - else if (value == 'Report a false positive') { |
143 | | - vscode.env.openExternal( |
144 | | - vscode.Uri.parse( |
145 | | - 'https://github.com/vuejs/language-tools/pull/4206' |
146 | | - ) |
147 | | - ); |
148 | | - } |
149 | | - }); |
| 48 | + if ( |
| 49 | + extension.id === 'svelte.svelte-vscode' |
| 50 | + && semver.lt(extension.packageJSON.version, '108.4.0') |
| 51 | + ) { |
| 52 | + vscode.window.showWarningMessage(`The ${extension.packageJSON.displayName}(${extension.id}) extension is incompatible with the Vue extension. Please update ${extension.packageJSON.displayName} to the latest version to avoid issues.`); |
150 | 53 | } |
151 | | - }); |
152 | | -} |
153 | | - |
154 | | -export function useHybridModeStatusItem() { |
155 | | - const item = vscode.languages.createLanguageStatusItem( |
156 | | - 'vue-hybrid-mode', |
157 | | - config.server.includeLanguages |
158 | | - ); |
159 | | - |
160 | | - item.text = 'Hybrid Mode'; |
161 | | - item.detail = |
162 | | - (enabledHybridMode.value ? 'Enabled' : 'Disabled') + |
163 | | - (config.server.hybridMode === 'auto' ? ' (Auto)' : ''); |
164 | | - item.command = { |
165 | | - title: 'Open Setting', |
166 | | - command: 'workbench.action.openSettings', |
167 | | - arguments: ['vue.server.hybridMode'], |
168 | | - }; |
169 | | - |
170 | | - if (!enabledHybridMode.value) { |
171 | | - item.severity = vscode.LanguageStatusSeverity.Warning; |
| 54 | + } |
| 55 | + if ( |
| 56 | + (vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) || |
| 57 | + (workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0')) |
| 58 | + ) { |
| 59 | + let msg = `TSDK >= 5.3.0 is required (VSCode TSDK: ${vscodeTsdkVersion.value}`; |
| 60 | + if (workspaceTsdkVersion.value) { |
| 61 | + msg += `, Workspace TSDK: ${workspaceTsdkVersion.value}`; |
| 62 | + } |
| 63 | + msg += `).`; |
| 64 | + vscode.window.showWarningMessage(msg); |
172 | 65 | } |
173 | 66 | } |
174 | 67 |
|
|
0 commit comments