@vue/language-service 2.0.23-alpha.1 → 2.0.26-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -916,7 +916,7 @@
916
916
  ],
917
917
  "description": {
918
918
  "kind": "markdown",
919
- "value": "\n在一个 `*.vue` 文件中可以为任何项目特定需求使用额外的自定义块。举例来说,一个用作写文档的 `<docs>` 块。这里是一些自定义块的真实用例:\n\n- [Gridsome:`<page-query>`](https://gridsome.org/docs/querying-data/)\n- [vite-plugin-vue-gql:`<gql>`](https://github.com/wheatjs/vite-plugin-vue-gql)\n- [vue-i18n:`<i18n>`](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n#i18n-custom-block)\n\n自定义块的处理需要依赖工具链。如果你想要在构建中集成你的自定义语块,请参见 [SFC 自定义块集成工具链指南](https://cn.vuejs.org/guide/scaling-up/tooling.html#sfc-custom-block-integrations)获取更多细节。\n"
919
+ "value": "\n在一个 `*.vue` 文件中可以为任何项目特定需求使用额外的自定义块。举例来说,一个用作写文档的 `<docs>` 块。这里是一些自定义块的真实用例:\n\n- [Gridsome:`<page-query>`](https://gridsome.org/docs/querying-data/)\n- [vite-plugin-vue-gql:`<gql>`](https://github.com/wheatjs/vite-plugin-vue-gql)\n- [vue-i18n:`<i18n>`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n#i18n-custom-block)\n\n自定义块的处理需要依赖工具链。如果你想要在构建中集成你的自定义语块,请参见 [SFC 自定义块集成工具链指南](https://cn.vuejs.org/guide/scaling-up/tooling.html#sfc-custom-block-integrations)获取更多细节。\n"
920
920
  },
921
921
  "references": [
922
922
  {
package/index.d.ts CHANGED
@@ -3,13 +3,13 @@ export * from '@vue/language-core';
3
3
  export * from './lib/ideFeatures/nameCasing';
4
4
  export * from './lib/types';
5
5
  import type { LanguageServicePlugin } from '@volar/language-service';
6
+ import { VueCompilerOptions } from '@vue/language-core';
7
+ declare module '@volar/language-service' {
8
+ interface ProjectContext {
9
+ vue?: {
10
+ compilerOptions: VueCompilerOptions;
11
+ };
12
+ }
13
+ }
6
14
  export declare function getFullLanguageServicePlugins(ts: typeof import('typescript')): LanguageServicePlugin[];
7
15
  export declare function getHybridModeLanguageServicePlugins(ts: typeof import('typescript'), getTsPluginClient: typeof import("@vue/typescript-plugin/lib/client")): LanguageServicePlugin[];
8
- export declare const commands: {
9
- parseSfc: string;
10
- detectNameCasing: string;
11
- convertTagsToKebabCase: string;
12
- convertTagsToPascalCase: string;
13
- convertPropsToKebabCase: string;
14
- convertPropsToCamelCase: string;
15
- };
package/index.js CHANGED
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.commands = void 0;
18
17
  exports.getFullLanguageServicePlugins = getFullLanguageServicePlugins;
19
18
  exports.getHybridModeLanguageServicePlugins = getHybridModeLanguageServicePlugins;
20
19
  __exportStar(require("@volar/language-service"), exports);
@@ -62,12 +61,16 @@ function getFullLanguageServicePlugins(ts) {
62
61
  ...plugin,
63
62
  create(context) {
64
63
  const created = plugin.create(context);
65
- if (!context.language.typescript) {
64
+ if (!context.project.typescript) {
66
65
  return created;
67
66
  }
68
67
  const languageService = created.provide['typescript/languageService']();
69
- if (context.language.vue) {
70
- (0, common_1.decorateLanguageServiceForVue)(context.language, languageService, context.language.vue.compilerOptions, ts, false, context.language.typescript.asScriptId);
68
+ if (context.project.vue) {
69
+ const proxy = (0, common_1.proxyLanguageServiceForVue)(ts, context.language, languageService, context.project.vue.compilerOptions, context.project.typescript.asUri);
70
+ languageService.getCompletionsAtPosition = proxy.getCompletionsAtPosition;
71
+ languageService.getCompletionEntryDetails = proxy.getCompletionEntryDetails;
72
+ languageService.getCodeFixesAtPosition = proxy.getCodeFixesAtPosition;
73
+ languageService.getQuickInfoAtPosition = proxy.getQuickInfoAtPosition;
71
74
  }
72
75
  return created;
73
76
  },
@@ -77,7 +80,7 @@ function getFullLanguageServicePlugins(ts) {
77
80
  }
78
81
  return plugins;
79
82
  function getTsPluginClientForLSP(context) {
80
- if (!context.language.typescript) {
83
+ if (!context.project.typescript) {
81
84
  return;
82
85
  }
83
86
  const languageService = context.inject('typescript/languageService');
@@ -88,9 +91,9 @@ function getFullLanguageServicePlugins(ts) {
88
91
  typescript: ts,
89
92
  language: context.language,
90
93
  languageService,
91
- languageServiceHost: context.language.typescript.languageServiceHost,
94
+ languageServiceHost: context.project.typescript.languageServiceHost,
92
95
  isTsPlugin: false,
93
- getFileId: context.language.typescript.asScriptId,
96
+ getFileId: context.project.typescript.asUri,
94
97
  };
95
98
  return {
96
99
  async collectExtractProps(...args) {
@@ -135,14 +138,6 @@ function getHybridModeLanguageServicePlugins(ts, getTsPluginClient) {
135
138
  }
136
139
  return plugins;
137
140
  }
138
- exports.commands = {
139
- parseSfc: 'vue.parseSfc',
140
- detectNameCasing: 'vue.detectNameCasing',
141
- convertTagsToKebabCase: 'vue.convertTagsToKebabCase',
142
- convertTagsToPascalCase: 'vue.convertTagsToPascalCase',
143
- convertPropsToKebabCase: 'vue.convertPropsToKebabCase',
144
- convertPropsToCamelCase: 'vue.convertPropsToCamelCase',
145
- };
146
141
  function getCommonLanguageServicePlugins(ts, getTsPluginClient) {
147
142
  return [
148
143
  (0, volar_service_typescript_twoslash_queries_1.create)(ts),
@@ -171,7 +166,7 @@ function getCommonLanguageServicePlugins(ts, getTsPluginClient) {
171
166
  name: 'vue-parse-sfc',
172
167
  capabilities: {
173
168
  executeCommandProvider: {
174
- commands: [exports.commands.parseSfc],
169
+ commands: [types_1.commands.parseSfc],
175
170
  },
176
171
  },
177
172
  create() {
@@ -187,30 +182,30 @@ function getCommonLanguageServicePlugins(ts, getTsPluginClient) {
187
182
  capabilities: {
188
183
  executeCommandProvider: {
189
184
  commands: [
190
- exports.commands.detectNameCasing,
191
- exports.commands.convertTagsToKebabCase,
192
- exports.commands.convertTagsToPascalCase,
193
- exports.commands.convertPropsToKebabCase,
194
- exports.commands.convertPropsToCamelCase,
185
+ types_1.commands.detectNameCasing,
186
+ types_1.commands.convertTagsToKebabCase,
187
+ types_1.commands.convertTagsToPascalCase,
188
+ types_1.commands.convertPropsToKebabCase,
189
+ types_1.commands.convertPropsToCamelCase,
195
190
  ],
196
191
  }
197
192
  },
198
193
  create(context) {
199
194
  return {
200
195
  executeCommand(command, [uri]) {
201
- if (command === exports.commands.detectNameCasing) {
196
+ if (command === types_1.commands.detectNameCasing) {
202
197
  return (0, nameCasing_1.detect)(context, vscode_uri_1.URI.parse(uri));
203
198
  }
204
- else if (command === exports.commands.convertTagsToKebabCase) {
199
+ else if (command === types_1.commands.convertTagsToKebabCase) {
205
200
  return (0, nameCasing_1.convertTagName)(context, vscode_uri_1.URI.parse(uri), types_1.TagNameCasing.Kebab, getTsPluginClient(context));
206
201
  }
207
- else if (command === exports.commands.convertTagsToPascalCase) {
202
+ else if (command === types_1.commands.convertTagsToPascalCase) {
208
203
  return (0, nameCasing_1.convertTagName)(context, vscode_uri_1.URI.parse(uri), types_1.TagNameCasing.Pascal, getTsPluginClient(context));
209
204
  }
210
- else if (command === exports.commands.convertPropsToKebabCase) {
205
+ else if (command === types_1.commands.convertPropsToKebabCase) {
211
206
  return (0, nameCasing_1.convertAttrName)(context, vscode_uri_1.URI.parse(uri), types_1.AttrNameCasing.Kebab, getTsPluginClient(context));
212
207
  }
213
- else if (command === exports.commands.convertPropsToCamelCase) {
208
+ else if (command === types_1.commands.convertPropsToCamelCase) {
214
209
  return (0, nameCasing_1.convertAttrName)(context, vscode_uri_1.URI.parse(uri), types_1.AttrNameCasing.Camel, getTsPluginClient(context));
215
210
  }
216
211
  },
@@ -56,7 +56,7 @@ function create(ts, getTsPluginClient) {
56
56
  }
57
57
  let ast;
58
58
  let sourceCodeOffset = document.offsetAt(selection);
59
- const fileName = context.language.typescript?.asFileName(sourceScript.id)
59
+ const fileName = context.project.typescript?.asFileName(sourceScript.id)
60
60
  ?? sourceScript.id.fsPath.replace(/\\/g, '/');
61
61
  if (sourceScript.generated) {
62
62
  const serviceScript = sourceScript.generated.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
@@ -15,12 +15,12 @@ function create(ts, getTsPluginClient) {
15
15
  // documentDropEditsProvider: true,
16
16
  },
17
17
  create(context) {
18
- if (!context.language.vue) {
18
+ if (!context.project.vue) {
19
19
  return {};
20
20
  }
21
21
  let casing = types_1.TagNameCasing.Pascal; // TODO
22
22
  const tsPluginClient = getTsPluginClient?.(context);
23
- const vueCompilerOptions = context.language.vue.compilerOptions;
23
+ const vueCompilerOptions = context.project.vue.compilerOptions;
24
24
  return {
25
25
  async provideDocumentDropEdits(document, _position, dataTransfer) {
26
26
  if (document.languageId !== 'html') {
@@ -53,7 +53,7 @@ function create(ts, getTsPluginClient) {
53
53
  const additionalEdit = {};
54
54
  const code = [...(0, language_core_1.forEachEmbeddedCode)(vueVirtualCode)].find(code => code.id === (sfc.scriptSetup ? 'scriptsetup_raw' : 'script_raw'));
55
55
  const lastImportNode = (0, vue_extract_file_1.getLastImportNode)(ts, script.ast);
56
- const incomingFileName = context.language.typescript?.asFileName(vscode_uri_1.URI.parse(importUri))
56
+ const incomingFileName = context.project.typescript?.asFileName(vscode_uri_1.URI.parse(importUri))
57
57
  ?? vscode_uri_1.URI.parse(importUri).fsPath.replace(/\\/g, '/');
58
58
  let importPath;
59
59
  const serviceScript = sourceScript.generated?.languagePlugin.typescript?.getServiceScript(vueVirtualCode);
@@ -154,6 +154,18 @@ function create() {
154
154
  return result;
155
155
  });
156
156
  },
157
+ async provideCompletionItems(document, position, context, token) {
158
+ const result = await htmlPluginInstance.provideCompletionItems?.(document, position, context, token);
159
+ if (!result) {
160
+ return;
161
+ }
162
+ result.items = [
163
+ ...result.items.filter(item => item.label !== '!DOCTYPE' && item.label !== 'Custom Blocks'),
164
+ createCompletionItemWithTs(result.items.find(item => item.label === 'script')),
165
+ createCompletionItemWithTs(result.items.find(item => item.label === 'script setup')),
166
+ ];
167
+ return result;
168
+ },
157
169
  };
158
170
  },
159
171
  };
@@ -166,4 +178,14 @@ function create() {
166
178
  }
167
179
  }
168
180
  }
181
+ function createCompletionItemWithTs(base) {
182
+ return {
183
+ ...base,
184
+ label: base.label + ' lang="ts"',
185
+ textEdit: {
186
+ ...base.textEdit,
187
+ newText: base.textEdit.newText + ' lang="ts"',
188
+ }
189
+ };
190
+ }
169
191
  //# sourceMappingURL=vue-sfc.js.map
@@ -111,10 +111,10 @@ function create(mode, ts, getTsPluginClient) {
111
111
  if (!isSupportedDocument(document)) {
112
112
  return;
113
113
  }
114
- if (!context.language.vue) {
114
+ if (!context.project.vue) {
115
115
  return;
116
116
  }
117
- const vueCompilerOptions = context.language.vue.compilerOptions;
117
+ const vueCompilerOptions = context.project.vue.compilerOptions;
118
118
  let sync;
119
119
  let currentVersion;
120
120
  const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
@@ -141,10 +141,10 @@ function create(mode, ts, getTsPluginClient) {
141
141
  if (!isSupportedDocument(document)) {
142
142
  return;
143
143
  }
144
- if (!context.language.vue) {
144
+ if (!context.project.vue) {
145
145
  return;
146
146
  }
147
- const vueCompilerOptions = context.language.vue.compilerOptions;
147
+ const vueCompilerOptions = context.project.vue.compilerOptions;
148
148
  const enabled = await context.env.getConfiguration?.('vue.inlayHints.missingProps') ?? false;
149
149
  if (!enabled) {
150
150
  return;
@@ -305,10 +305,10 @@ function create(mode, ts, getTsPluginClient) {
305
305
  if (!isSupportedDocument(document)) {
306
306
  return;
307
307
  }
308
- if (!context.language.vue) {
308
+ if (!context.project.vue) {
309
309
  return;
310
310
  }
311
- const vueCompilerOptions = context.language.vue.compilerOptions;
311
+ const vueCompilerOptions = context.project.vue.compilerOptions;
312
312
  const languageService = context.inject('typescript/languageService');
313
313
  if (!languageService) {
314
314
  return;
package/lib/types.d.ts CHANGED
@@ -6,5 +6,13 @@ export declare enum AttrNameCasing {
6
6
  Kebab = 0,
7
7
  Camel = 1
8
8
  }
9
+ export declare const commands: {
10
+ parseSfc: string;
11
+ detectNameCasing: string;
12
+ convertTagsToKebabCase: string;
13
+ convertTagsToPascalCase: string;
14
+ convertPropsToKebabCase: string;
15
+ convertPropsToCamelCase: string;
16
+ };
9
17
  export * from '@volar/language-service/lib/types';
10
18
  export * from '@vue/language-core/lib/types';
package/lib/types.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AttrNameCasing = exports.TagNameCasing = void 0;
17
+ exports.commands = exports.AttrNameCasing = exports.TagNameCasing = void 0;
18
18
  var TagNameCasing;
19
19
  (function (TagNameCasing) {
20
20
  TagNameCasing[TagNameCasing["Kebab"] = 0] = "Kebab";
@@ -25,6 +25,14 @@ var AttrNameCasing;
25
25
  AttrNameCasing[AttrNameCasing["Kebab"] = 0] = "Kebab";
26
26
  AttrNameCasing[AttrNameCasing["Camel"] = 1] = "Camel";
27
27
  })(AttrNameCasing || (exports.AttrNameCasing = AttrNameCasing = {}));
28
+ exports.commands = {
29
+ parseSfc: 'vue.parseSfc',
30
+ detectNameCasing: 'vue.detectNameCasing',
31
+ convertTagsToKebabCase: 'vue.convertTagsToKebabCase',
32
+ convertTagsToPascalCase: 'vue.convertTagsToPascalCase',
33
+ convertPropsToKebabCase: 'vue.convertPropsToKebabCase',
34
+ convertPropsToCamelCase: 'vue.convertPropsToCamelCase',
35
+ };
28
36
  // only export types of depend packages
29
37
  __exportStar(require("@volar/language-service/lib/types"), exports);
30
38
  __exportStar(require("@vue/language-core/lib/types"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "2.0.23-alpha.1",
3
+ "version": "2.0.26-alpha.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -16,23 +16,23 @@
16
16
  "update-html-data": "node ./scripts/update-html-data.js"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/language-core": "~2.4.0-alpha.0",
20
- "@volar/language-service": "~2.4.0-alpha.0",
21
- "@volar/typescript": "~2.4.0-alpha.0",
19
+ "@volar/language-core": "~2.4.0-alpha.11",
20
+ "@volar/language-service": "~2.4.0-alpha.11",
21
+ "@volar/typescript": "~2.4.0-alpha.11",
22
22
  "@vue/compiler-dom": "^3.4.0",
23
- "@vue/language-core": "2.0.23-alpha.1",
23
+ "@vue/language-core": "2.0.26-alpha.0",
24
24
  "@vue/shared": "^3.4.0",
25
- "@vue/typescript-plugin": "2.0.23-alpha.1",
25
+ "@vue/typescript-plugin": "2.0.26-alpha.0",
26
26
  "computeds": "^0.0.1",
27
27
  "path-browserify": "^1.0.1",
28
- "volar-service-css": "0.0.55",
29
- "volar-service-emmet": "0.0.55",
30
- "volar-service-html": "0.0.55",
31
- "volar-service-json": "0.0.55",
32
- "volar-service-pug": "0.0.55",
33
- "volar-service-pug-beautify": "0.0.55",
34
- "volar-service-typescript": "0.0.55",
35
- "volar-service-typescript-twoslash-queries": "0.0.55",
28
+ "volar-service-css": "volar-2.4",
29
+ "volar-service-emmet": "volar-2.4",
30
+ "volar-service-html": "volar-2.4",
31
+ "volar-service-json": "volar-2.4",
32
+ "volar-service-pug": "volar-2.4",
33
+ "volar-service-pug-beautify": "volar-2.4",
34
+ "volar-service-typescript": "volar-2.4",
35
+ "volar-service-typescript-twoslash-queries": "volar-2.4",
36
36
  "vscode-html-languageservice": "^5.2.0",
37
37
  "vscode-languageserver-textdocument": "^1.0.11",
38
38
  "vscode-uri": "^3.0.8"
@@ -40,8 +40,8 @@
40
40
  "devDependencies": {
41
41
  "@types/node": "latest",
42
42
  "@types/path-browserify": "latest",
43
- "@volar/kit": "~2.4.0-alpha.0",
43
+ "@volar/kit": "~2.4.0-alpha.11",
44
44
  "vscode-languageserver-protocol": "^3.17.5"
45
45
  },
46
- "gitHead": "70cb34e9d58afd603d50cb5b870116b189f4662b"
46
+ "gitHead": "7ace5046de671cda22fac8dd7d71b3658489c5c6"
47
47
  }