@vue/language-service 3.0.0-alpha.0 → 3.0.0-alpha.10

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.
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from '@vue/language-core';
3
3
  export * from './lib/nameCasing';
4
4
  export * from './lib/types';
5
5
  import type { LanguageServicePlugin } from '@volar/language-service';
6
- import { VueCompilerOptions } from '@vue/language-core';
6
+ import { type VueCompilerOptions } from '@vue/language-core';
7
7
  declare module '@volar/language-service' {
8
8
  interface ProjectContext {
9
9
  vue?: {
@@ -12,4 +12,7 @@ declare module '@volar/language-service' {
12
12
  }
13
13
  }
14
14
  export declare function getFullLanguageServicePlugins(ts: typeof import('typescript')): LanguageServicePlugin<any>[];
15
- export declare function getHybridModeLanguageServicePlugins(ts: typeof import('typescript'), getTsPluginClient: import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin<any>[];
15
+ import type * as ts from 'typescript';
16
+ export declare function getHybridModeLanguageServicePlugins(ts: typeof import('typescript'), tsPluginClient: (import('@vue/typescript-plugin/lib/requests').Requests & {
17
+ getDocumentHighlights: (fileName: string, position: number) => Promise<ts.DocumentHighlights[] | null>;
18
+ }) | undefined): LanguageServicePlugin<any>[];
package/index.js CHANGED
@@ -36,6 +36,7 @@ const vue_compiler_dom_errors_1 = require("./lib/plugins/vue-compiler-dom-errors
36
36
  const vue_complete_define_assignment_1 = require("./lib/plugins/vue-complete-define-assignment");
37
37
  const vue_directive_comments_1 = require("./lib/plugins/vue-directive-comments");
38
38
  const vue_document_drop_1 = require("./lib/plugins/vue-document-drop");
39
+ const vue_document_highlights_1 = require("./lib/plugins/vue-document-highlights");
39
40
  const vue_document_links_1 = require("./lib/plugins/vue-document-links");
40
41
  const vue_extract_file_1 = require("./lib/plugins/vue-extract-file");
41
42
  const vue_inlayhints_1 = require("./lib/plugins/vue-inlayhints");
@@ -105,31 +106,31 @@ function getFullLanguageServicePlugins(ts) {
105
106
  };
106
107
  return {
107
108
  async collectExtractProps(...args) {
108
- return await collectExtractProps_1.collectExtractProps.apply(requestContext, args);
109
+ return collectExtractProps_1.collectExtractProps.apply(requestContext, args);
109
110
  },
110
111
  async getPropertiesAtLocation(...args) {
111
- return await getPropertiesAtLocation_1.getPropertiesAtLocation.apply(requestContext, args);
112
+ return getPropertiesAtLocation_1.getPropertiesAtLocation.apply(requestContext, args);
112
113
  },
113
114
  async getImportPathForFile(...args) {
114
- return await getImportPathForFile_1.getImportPathForFile.apply(requestContext, args);
115
+ return getImportPathForFile_1.getImportPathForFile.apply(requestContext, args);
115
116
  },
116
117
  async getComponentEvents(...args) {
117
- return await getComponentEvents_1.getComponentEvents.apply(requestContext, args);
118
+ return getComponentEvents_1.getComponentEvents.apply(requestContext, args);
118
119
  },
119
120
  async getComponentDirectives(...args) {
120
- return await getComponentDirectives_1.getComponentDirectives.apply(requestContext, args);
121
+ return getComponentDirectives_1.getComponentDirectives.apply(requestContext, args);
121
122
  },
122
123
  async getComponentNames(...args) {
123
- return await getComponentNames_1.getComponentNames.apply(requestContext, args);
124
+ return getComponentNames_1.getComponentNames.apply(requestContext, args);
124
125
  },
125
126
  async getComponentProps(...args) {
126
- return await getComponentProps_1.getComponentProps.apply(requestContext, args);
127
+ return getComponentProps_1.getComponentProps.apply(requestContext, args);
127
128
  },
128
129
  async getElementAttrs(...args) {
129
- return await getElementAttrs_1.getElementAttrs.apply(requestContext, args);
130
+ return getElementAttrs_1.getElementAttrs.apply(requestContext, args);
130
131
  },
131
132
  async getElementNames(...args) {
132
- return await getElementNames_1.getElementNames.apply(requestContext, args);
133
+ return getElementNames_1.getElementNames.apply(requestContext, args);
133
134
  },
134
135
  async getQuickInfoAtPosition(fileName, position) {
135
136
  const languageService = context.getLanguageService();
@@ -138,8 +139,7 @@ function getFullLanguageServicePlugins(ts) {
138
139
  if (!sourceScript) {
139
140
  return;
140
141
  }
141
- const document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
142
- const hover = await languageService.getHover(uri, document.positionAt(position));
142
+ const hover = await languageService.getHover(uri, position);
143
143
  let text = '';
144
144
  if (typeof hover?.contents === 'string') {
145
145
  text = hover.contents;
@@ -167,12 +167,15 @@ function getFullLanguageServicePlugins(ts) {
167
167
  };
168
168
  }
169
169
  }
170
- function getHybridModeLanguageServicePlugins(ts, getTsPluginClient) {
170
+ function getHybridModeLanguageServicePlugins(ts, tsPluginClient) {
171
171
  const plugins = [
172
172
  (0, syntactic_1.create)(ts),
173
173
  (0, docCommentTemplate_1.create)(ts),
174
- ...getCommonLanguageServicePlugins(ts, () => getTsPluginClient)
174
+ ...getCommonLanguageServicePlugins(ts, () => tsPluginClient)
175
175
  ];
176
+ if (tsPluginClient) {
177
+ plugins.push((0, vue_document_highlights_1.create)(tsPluginClient.getDocumentHighlights));
178
+ }
176
179
  for (const plugin of plugins) {
177
180
  // avoid affecting TS plugin
178
181
  delete plugin.capabilities.semanticTokensProvider;
@@ -191,8 +194,8 @@ function getCommonLanguageServicePlugins(ts, getTsPluginClient) {
191
194
  (0, vue_compiler_dom_errors_1.create)(),
192
195
  (0, vue_sfc_1.create)(),
193
196
  (0, vue_twoslash_queries_1.create)(getTsPluginClient),
194
- (0, vue_document_links_1.create)(),
195
197
  (0, vue_document_drop_1.create)(ts, getTsPluginClient),
198
+ (0, vue_document_links_1.create)(),
196
199
  (0, vue_complete_define_assignment_1.create)(),
197
200
  (0, vue_autoinsert_dotvalue_1.create)(ts, getTsPluginClient),
198
201
  (0, vue_autoinsert_space_1.create)(),
@@ -23,55 +23,67 @@ function create() {
23
23
  return diagnostics;
24
24
  },
25
25
  /**
26
- * If the editing position is within the virtual code and navigation is enabled,
27
- * skip the CSS renaming feature.
26
+ * If the position is within the virtual code and navigation is enabled,
27
+ * skip the CSS navigation feature.
28
28
  */
29
+ provideReferences(document, position) {
30
+ if (isWithinNavigationVirtualCode(document, position)) {
31
+ return;
32
+ }
33
+ return worker(document, (stylesheet, cssLs) => {
34
+ return cssLs.findReferences(document, position, stylesheet);
35
+ });
36
+ },
29
37
  provideRenameRange(document, position) {
30
- do {
31
- const uri = vscode_uri_1.URI.parse(document.uri);
32
- const decoded = context.decodeEmbeddedDocumentUri(uri);
33
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
34
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
35
- if (!sourceScript?.generated || !virtualCode?.id.startsWith('style_')) {
36
- break;
37
- }
38
- const root = sourceScript.generated.root;
39
- if (!(root instanceof language_core_1.VueVirtualCode)) {
40
- break;
41
- }
42
- const block = root.sfc.styles.find(style => style.name === decoded[1]);
43
- if (!block) {
44
- break;
45
- }
46
- let script;
47
- for (const [key, value] of sourceScript.generated.embeddedCodes) {
48
- if (key.startsWith('script_')) {
49
- script = value;
50
- break;
51
- }
52
- }
53
- if (!script) {
54
- break;
55
- }
56
- const offset = document.offsetAt(position) + block.startTagEnd;
57
- for (const { sourceOffsets, lengths, data } of script.mappings) {
58
- if (!sourceOffsets.length
59
- || !data.navigation
60
- || typeof data.navigation === 'object' && !data.navigation.shouldRename) {
61
- continue;
62
- }
63
- const start = sourceOffsets[0];
64
- const end = sourceOffsets.at(-1) + lengths.at(-1);
65
- if (offset >= start && offset <= end) {
66
- return;
67
- }
68
- }
69
- } while (0);
38
+ if (isWithinNavigationVirtualCode(document, position)) {
39
+ return;
40
+ }
70
41
  return worker(document, (stylesheet, cssLs) => {
71
42
  return cssLs.prepareRename(document, position, stylesheet);
72
43
  });
73
44
  }
74
45
  };
46
+ function isWithinNavigationVirtualCode(document, position) {
47
+ const uri = vscode_uri_1.URI.parse(document.uri);
48
+ const decoded = context.decodeEmbeddedDocumentUri(uri);
49
+ const sourceScript = decoded && context.language.scripts.get(decoded[0]);
50
+ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
51
+ if (!sourceScript?.generated || !virtualCode?.id.startsWith('style_')) {
52
+ return false;
53
+ }
54
+ const root = sourceScript.generated.root;
55
+ if (!(root instanceof language_core_1.VueVirtualCode)) {
56
+ return false;
57
+ }
58
+ const block = root.sfc.styles.find(style => style.name === decoded[1]);
59
+ if (!block) {
60
+ return false;
61
+ }
62
+ let script;
63
+ for (const [key, value] of sourceScript.generated.embeddedCodes) {
64
+ if (key.startsWith('script_')) {
65
+ script = value;
66
+ break;
67
+ }
68
+ }
69
+ if (!script) {
70
+ return false;
71
+ }
72
+ const offset = document.offsetAt(position) + block.startTagEnd;
73
+ for (const { sourceOffsets, lengths, data } of script.mappings) {
74
+ if (!sourceOffsets.length
75
+ || !data.navigation
76
+ || typeof data.navigation === 'object' && !data.navigation.shouldRename) {
77
+ continue;
78
+ }
79
+ const start = sourceOffsets[0];
80
+ const end = sourceOffsets.at(-1) + lengths.at(-1);
81
+ if (offset >= start && offset <= end) {
82
+ return true;
83
+ }
84
+ }
85
+ return false;
86
+ }
75
87
  function worker(document, callback) {
76
88
  const cssLs = getCssLs(document);
77
89
  if (!cssLs) {
@@ -1,2 +1,2 @@
1
- import { LanguageServicePlugin } from '../types';
1
+ import type { LanguageServicePlugin } from '../types';
2
2
  export declare function create(): LanguageServicePlugin;
@@ -1,2 +1,2 @@
1
- import { LanguageServiceContext, LanguageServicePlugin } from '../types';
1
+ import { type LanguageServiceContext, type LanguageServicePlugin } from '../types';
2
2
  export declare function create(ts: typeof import('typescript'), getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
@@ -0,0 +1,3 @@
1
+ import type { LanguageServicePlugin } from '@volar/language-service';
2
+ import type * as ts from 'typescript';
3
+ export declare function create(getDocumentHighlights: (fileName: string, position: number) => Promise<ts.DocumentHighlights[] | null>): LanguageServicePlugin;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const language_core_1 = require("@vue/language-core");
5
+ const vscode_uri_1 = require("vscode-uri");
6
+ function create(getDocumentHighlights) {
7
+ return {
8
+ name: 'vue-document-highlights',
9
+ capabilities: {
10
+ documentHighlightProvider: true,
11
+ },
12
+ create(context) {
13
+ return {
14
+ async provideDocumentHighlights(document, position) {
15
+ const uri = vscode_uri_1.URI.parse(document.uri);
16
+ const decoded = context.decodeEmbeddedDocumentUri(uri);
17
+ const sourceScript = decoded && context.language.scripts.get(decoded[0]);
18
+ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
19
+ if (!sourceScript?.generated || virtualCode?.id !== 'main') {
20
+ return;
21
+ }
22
+ const root = sourceScript.generated.root;
23
+ if (!(root instanceof language_core_1.VueVirtualCode)) {
24
+ return;
25
+ }
26
+ const result = await getDocumentHighlights(root.fileName, document.offsetAt(position));
27
+ return result
28
+ ?.filter(({ fileName }) => fileName === root.fileName)
29
+ .flatMap(({ highlightSpans }) => highlightSpans)
30
+ .map(({ textSpan, kind }) => ({
31
+ range: {
32
+ start: document.positionAt(textSpan.start),
33
+ end: document.positionAt(textSpan.start + textSpan.length),
34
+ },
35
+ kind: kind === 'reference'
36
+ ? 2
37
+ : kind === 'writtenReference'
38
+ ? 3
39
+ : 1,
40
+ }));
41
+ },
42
+ };
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=vue-document-highlights.js.map
@@ -16,52 +16,84 @@ function create() {
16
16
  const decoded = context.decodeEmbeddedDocumentUri(uri);
17
17
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
18
18
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
19
- if (!sourceScript?.generated || virtualCode?.id !== 'template') {
19
+ if (!sourceScript?.generated || (virtualCode?.id !== 'template' && virtualCode?.id !== "scriptsetup_raw")) {
20
20
  return;
21
21
  }
22
22
  const root = sourceScript.generated.root;
23
23
  if (!(root instanceof language_core_1.VueVirtualCode)) {
24
24
  return;
25
25
  }
26
- const result = [];
27
26
  const { sfc } = root;
28
27
  const codegen = language_core_1.tsCodegen.get(sfc);
29
- const scopedClasses = codegen?.getGeneratedTemplate()?.scopedClasses ?? [];
30
- const styleClasses = new Map();
31
- const option = root.vueCompilerOptions.experimentalResolveStyleCssClasses;
32
- for (let i = 0; i < sfc.styles.length; i++) {
33
- const style = sfc.styles[i];
34
- if (option === 'always' || (option === 'scoped' && style.scoped)) {
35
- for (const className of style.classNames) {
36
- if (!styleClasses.has(className.text.slice(1))) {
37
- styleClasses.set(className.text.slice(1), []);
28
+ const result = [];
29
+ if (virtualCode.id === 'template') {
30
+ const scopedClasses = codegen?.getGeneratedTemplate()?.scopedClasses ?? [];
31
+ const styleClasses = new Map();
32
+ const option = root.vueCompilerOptions.experimentalResolveStyleCssClasses;
33
+ for (let i = 0; i < sfc.styles.length; i++) {
34
+ const style = sfc.styles[i];
35
+ if (option === 'always' || (option === 'scoped' && style.scoped)) {
36
+ for (const className of style.classNames) {
37
+ if (!styleClasses.has(className.text.slice(1))) {
38
+ styleClasses.set(className.text.slice(1), []);
39
+ }
40
+ styleClasses.get(className.text.slice(1)).push({
41
+ index: i,
42
+ style,
43
+ classOffset: className.offset,
44
+ });
38
45
  }
39
- styleClasses.get(className.text.slice(1)).push({
40
- index: i,
41
- style,
42
- classOffset: className.offset,
43
- });
44
46
  }
45
47
  }
46
- }
47
- for (const { className, offset } of scopedClasses) {
48
- const styles = styleClasses.get(className);
49
- if (styles) {
50
- for (const style of styles) {
51
- const styleDocumentUri = context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index);
52
- const styleVirtualCode = sourceScript.generated.embeddedCodes.get('style_' + style.index);
53
- if (!styleVirtualCode) {
54
- continue;
48
+ for (const { className, offset } of scopedClasses) {
49
+ const styles = styleClasses.get(className);
50
+ if (styles) {
51
+ for (const style of styles) {
52
+ const styleDocumentUri = context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index);
53
+ const styleVirtualCode = sourceScript.generated.embeddedCodes.get('style_' + style.index);
54
+ if (!styleVirtualCode) {
55
+ continue;
56
+ }
57
+ const styleDocument = context.documents.get(styleDocumentUri, styleVirtualCode.languageId, styleVirtualCode.snapshot);
58
+ const start = styleDocument.positionAt(style.classOffset);
59
+ const end = styleDocument.positionAt(style.classOffset + className.length + 1);
60
+ result.push({
61
+ range: {
62
+ start: document.positionAt(offset),
63
+ end: document.positionAt(offset + className.length),
64
+ },
65
+ target: context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index) + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
66
+ });
55
67
  }
56
- const styleDocument = context.documents.get(styleDocumentUri, styleVirtualCode.languageId, styleVirtualCode.snapshot);
57
- const start = styleDocument.positionAt(style.classOffset);
58
- const end = styleDocument.positionAt(style.classOffset + className.length + 1);
68
+ }
69
+ }
70
+ }
71
+ else if (virtualCode.id === 'scriptsetup_raw') {
72
+ if (!sfc.scriptSetup) {
73
+ return;
74
+ }
75
+ const templateVirtualCode = sourceScript.generated.embeddedCodes.get('template');
76
+ if (!templateVirtualCode) {
77
+ return;
78
+ }
79
+ const templateDocumentUri = context.encodeEmbeddedDocumentUri(decoded[0], 'template');
80
+ const templateDocument = context.documents.get(templateDocumentUri, templateVirtualCode.languageId, templateVirtualCode.snapshot);
81
+ const templateRefs = codegen?.getGeneratedTemplate()?.templateRefs;
82
+ const useTemplateRefs = codegen?.getScriptSetupRanges()?.useTemplateRef ?? [];
83
+ for (const { arg } of useTemplateRefs) {
84
+ if (!arg) {
85
+ continue;
86
+ }
87
+ const name = sfc.scriptSetup.content.slice(arg.start + 1, arg.end - 1);
88
+ for (const { offset } of templateRefs?.get(name) ?? []) {
89
+ const start = templateDocument.positionAt(offset);
90
+ const end = templateDocument.positionAt(offset + name.length);
59
91
  result.push({
60
92
  range: {
61
- start: document.positionAt(offset),
62
- end: document.positionAt(offset + className.length),
93
+ start: document.positionAt(arg.start + 1),
94
+ end: document.positionAt(arg.end - 1),
63
95
  },
64
- target: context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index) + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
96
+ target: templateDocumentUri + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
65
97
  });
66
98
  }
67
99
  }
@@ -1,5 +1,5 @@
1
1
  import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
2
- import { Sfc } from '@vue/language-core';
2
+ import { type Sfc } from '@vue/language-core';
3
3
  import type * as ts from 'typescript';
4
4
  export declare function create(ts: typeof import('typescript'), getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
5
5
  export declare function getLastImportNode(ts: typeof import('typescript'), sourceFile: ts.SourceFile): ts.Node | undefined;
@@ -0,0 +1,2 @@
1
+ import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
2
+ export declare function create(getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const language_core_1 = require("@vue/language-core");
5
+ const vscode_uri_1 = require("vscode-uri");
6
+ function create(getTsPluginClient) {
7
+ return {
8
+ name: 'vue-file-references',
9
+ capabilities: {
10
+ codeLensProvider: {
11
+ resolveProvider: true,
12
+ },
13
+ },
14
+ create(context) {
15
+ const tsPluginClient = getTsPluginClient?.(context);
16
+ void tsPluginClient;
17
+ return {
18
+ provideReferencesCodeLensRanges(document) {
19
+ return worker(document, context, root => {
20
+ if (root.sfc.template) {
21
+ return [{
22
+ start: document.positionAt(root.sfc.template.start + 1),
23
+ end: document.positionAt(root.sfc.template.start + 1 + 'template'.length),
24
+ }];
25
+ }
26
+ });
27
+ },
28
+ provideReferences(document, position) {
29
+ return worker(document, context, async (root) => {
30
+ if (!root.sfc.template) {
31
+ return;
32
+ }
33
+ const offset = document.offsetAt(position);
34
+ const start = root.sfc.template.start + 1;
35
+ const end = start + 'template'.length;
36
+ if (offset < start || offset > end) {
37
+ return;
38
+ }
39
+ console.time('[VVVIP] getFileReferences');
40
+ const references = await tsPluginClient?.getFileReferences(root.fileName) ?? [];
41
+ console.timeEnd('[VVVIP] getFileReferences');
42
+ return references.map(({ fileName, range }) => ({
43
+ uri: vscode_uri_1.URI.file(fileName).toString(),
44
+ range,
45
+ }));
46
+ });
47
+ },
48
+ };
49
+ },
50
+ };
51
+ function worker(document, context, callback) {
52
+ if (document.languageId !== 'vue-root-tags') {
53
+ return;
54
+ }
55
+ const uri = vscode_uri_1.URI.parse(document.uri);
56
+ const decoded = context.decodeEmbeddedDocumentUri(uri);
57
+ const sourceScript = decoded && context.language.scripts.get(decoded[0]);
58
+ const root = sourceScript?.generated?.root;
59
+ if (root instanceof language_core_1.VueVirtualCode) {
60
+ return callback(root);
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=vue-file-references.js.map
@@ -1,3 +1,3 @@
1
1
  import type { LanguageServiceContext } from '@volar/language-service';
2
- import { LanguageServicePlugin } from '../types';
2
+ import { type LanguageServicePlugin } from '../types';
3
3
  export declare function create(getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
@@ -23,7 +23,6 @@ function create(getTsPluginClient) {
23
23
  if (!context.project.vue) {
24
24
  return;
25
25
  }
26
- const vueCompilerOptions = context.project.vue.compilerOptions;
27
26
  const enabled = await context.env.getConfiguration?.('vue.inlayHints.missingProps') ?? false;
28
27
  if (!enabled) {
29
28
  return;
@@ -101,7 +100,7 @@ function create(getTsPluginClient) {
101
100
  attrText = attrText.slice('v-model:'.length);
102
101
  }
103
102
  else if (attrText === 'v-model') {
104
- attrText = vueCompilerOptions.target >= 3 ? 'modelValue' : 'value'; // TODO: support for experimentalModelPropName?
103
+ attrText = 'modelValue'; // TODO: support for experimentalModelPropName?
105
104
  }
106
105
  else if (attrText.startsWith('v-on:')) {
107
106
  attrText = 'on-' + (0, language_core_1.hyphenateAttr)(attrText.slice('v-on:'.length));
@@ -193,7 +193,9 @@ function create() {
193
193
  if (!result) {
194
194
  return;
195
195
  }
196
- result.items = result.items.filter(item => item.label !== '!DOCTYPE' && item.label !== 'Custom Blocks');
196
+ result.items = result.items.filter(item => item.label !== '!DOCTYPE' &&
197
+ item.label !== 'Custom Blocks' &&
198
+ item.label !== 'data-');
197
199
  const tags = sfcDataProvider?.provideTags();
198
200
  const scriptLangs = getLangs('script');
199
201
  const scriptItems = result.items.filter(item => item.label === 'script' || item.label === 'script setup');
@@ -0,0 +1,2 @@
1
+ import type { LanguageServicePlugin } from '../types';
2
+ export declare function create(): LanguageServicePlugin;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const language_core_1 = require("@vue/language-core");
5
+ const vscode_uri_1 = require("vscode-uri");
6
+ const utils_1 = require("./utils");
7
+ function create() {
8
+ return {
9
+ name: 'vue-document-drop',
10
+ capabilities: {
11
+ completionProvider: {},
12
+ },
13
+ create(context) {
14
+ return {
15
+ provideCompletionItems(document) {
16
+ if (!(0, utils_1.isTsDocument)(document)) {
17
+ return;
18
+ }
19
+ const uri = vscode_uri_1.URI.parse(document.uri);
20
+ const decoded = context.decodeEmbeddedDocumentUri(uri);
21
+ const sourceScript = decoded && context.language.scripts.get(decoded[0]);
22
+ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
23
+ if (!sourceScript?.generated || !virtualCode) {
24
+ return;
25
+ }
26
+ const root = sourceScript.generated.root;
27
+ if (!(root instanceof language_core_1.VueVirtualCode)) {
28
+ return;
29
+ }
30
+ const { sfc } = root;
31
+ const codegen = language_core_1.tsCodegen.get(sfc);
32
+ const scriptSetupRanges = codegen.getScriptSetupRanges();
33
+ for (const {} of scriptSetupRanges?.useTemplateRef ?? []) {
34
+ return {
35
+ isIncomplete: false,
36
+ items: [],
37
+ };
38
+ }
39
+ }
40
+ };
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=vue-template-refs.js.map
@@ -1,3 +1,3 @@
1
1
  import type { LanguageServiceContext } from '@volar/language-service';
2
- import { LanguageServicePlugin } from '../types';
2
+ import { type LanguageServicePlugin } from '../types';
3
3
  export declare function create(mode: 'html' | 'pug', getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
@@ -247,14 +247,19 @@ function create(mode, getTsPluginClient) {
247
247
  return [];
248
248
  }
249
249
  const { attrs, propInfos, events, directives } = tagInfo;
250
- const props = propInfos.map(prop => (0, language_core_1.hyphenateTag)(prop.name).startsWith('on-vnode-')
251
- ? 'onVue:' + prop.name.slice('onVnode'.length)
252
- : prop.name);
250
+ for (const prop of propInfos) {
251
+ if ((0, language_core_1.hyphenateTag)(prop.name).startsWith('on-vnode-')) {
252
+ prop.name = 'onVue:' + prop.name.slice('onVnode'.length);
253
+ }
254
+ }
253
255
  const attributes = [];
254
- const propsSet = new Set(props);
255
- for (const prop of [...props, ...attrs]) {
256
- const isGlobal = !propsSet.has(prop);
257
- const name = casing.attr === types_1.AttrNameCasing.Camel ? prop : (0, language_core_1.hyphenateAttr)(prop);
256
+ const propsSet = new Set(propInfos.map(prop => prop.name));
257
+ for (const prop of [
258
+ ...propInfos,
259
+ ...attrs.map(attr => ({ name: attr })),
260
+ ]) {
261
+ const isGlobal = prop.isAttribute || !propsSet.has(prop.name);
262
+ const name = casing.attr === types_1.AttrNameCasing.Camel ? prop.name : (0, language_core_1.hyphenateAttr)(prop.name);
258
263
  const isEvent = (0, language_core_1.hyphenateAttr)(name).startsWith('on-');
259
264
  if (isEvent) {
260
265
  const propNameBase = name.startsWith('on-')
@@ -282,6 +287,7 @@ function create(mode, getTsPluginClient) {
282
287
  attributes.push({
283
288
  name: propName,
284
289
  description: propKey,
290
+ valueSet: prop.values?.some(value => typeof value === 'string') ? '__deferred__' : undefined,
285
291
  }, {
286
292
  name: ':' + propName,
287
293
  description: propKey,
@@ -309,10 +315,13 @@ function create(mode, getTsPluginClient) {
309
315
  });
310
316
  }
311
317
  const models = [];
312
- for (const prop of [...props, ...attrs]) {
313
- if (prop.startsWith('onUpdate:')) {
314
- const isGlobal = !propsSet.has(prop);
315
- models.push([isGlobal, prop.slice('onUpdate:'.length)]);
318
+ for (const prop of [
319
+ ...propInfos,
320
+ ...attrs.map(attr => ({ name: attr })),
321
+ ]) {
322
+ if (prop.name.startsWith('onUpdate:')) {
323
+ const isGlobal = !propsSet.has(prop.name);
324
+ models.push([isGlobal, prop.name.slice('onUpdate:'.length)]);
316
325
  }
317
326
  }
318
327
  for (const event of events) {
@@ -38,7 +38,7 @@ function create(getTsPluginClient) {
38
38
  for (const [pointerPosition, hoverOffset] of hoverOffsets) {
39
39
  const map = context.language.maps.get(virtualCode, sourceScript);
40
40
  for (const [sourceOffset] of map.toSourceLocation(hoverOffset)) {
41
- const quickInfo = await tsPluginClient?.getQuickInfoAtPosition(root.fileName, sourceOffset);
41
+ const quickInfo = await tsPluginClient?.getQuickInfoAtPosition(root.fileName, document.positionAt(sourceOffset));
42
42
  if (quickInfo) {
43
43
  inlayHints.push({
44
44
  position: { line: pointerPosition.line, character: pointerPosition.character + 2 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.10",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -17,23 +17,23 @@
17
17
  "update-html-data": "node ./scripts/update-html-data.js"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "~2.4.11",
21
- "@volar/language-service": "~2.4.11",
22
- "@volar/typescript": "~2.4.11",
20
+ "@volar/language-core": "~2.4.13",
21
+ "@volar/language-service": "~2.4.13",
22
+ "@volar/typescript": "~2.4.13",
23
23
  "@vue/compiler-dom": "^3.5.0",
24
- "@vue/language-core": "3.0.0-alpha.0",
24
+ "@vue/language-core": "3.0.0-alpha.10",
25
25
  "@vue/shared": "^3.5.0",
26
- "@vue/typescript-plugin": "3.0.0-alpha.0",
27
- "alien-signals": "^1.0.3",
26
+ "@vue/typescript-plugin": "3.0.0-alpha.10",
27
+ "alien-signals": "^2.0.5",
28
28
  "path-browserify": "^1.0.1",
29
- "volar-service-css": "0.0.62",
30
- "volar-service-emmet": "0.0.62",
31
- "volar-service-html": "0.0.62",
32
- "volar-service-json": "0.0.62",
33
- "volar-service-pug": "0.0.62",
34
- "volar-service-pug-beautify": "0.0.62",
35
- "volar-service-typescript": "0.0.62",
36
- "volar-service-typescript-twoslash-queries": "0.0.62",
29
+ "volar-service-css": "0.0.64",
30
+ "volar-service-emmet": "0.0.64",
31
+ "volar-service-html": "0.0.64",
32
+ "volar-service-json": "0.0.64",
33
+ "volar-service-pug": "0.0.64",
34
+ "volar-service-pug-beautify": "0.0.64",
35
+ "volar-service-typescript": "0.0.64",
36
+ "volar-service-typescript-twoslash-queries": "0.0.64",
37
37
  "vscode-css-languageservice": "^6.3.1",
38
38
  "vscode-html-languageservice": "^5.2.0",
39
39
  "vscode-languageserver-textdocument": "^1.0.11",
@@ -42,8 +42,8 @@
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.10.4",
44
44
  "@types/path-browserify": "^1.0.1",
45
- "@volar/kit": "~2.4.11",
45
+ "@volar/kit": "~2.4.13",
46
46
  "vscode-languageserver-protocol": "^3.17.5"
47
47
  },
48
- "gitHead": "4b49cbe09097e482def4603b90f6c3b93bb2e913"
48
+ "gitHead": "28308b4f76cc80c7632f39ae7e0944f1889661a2"
49
49
  }