@vue/language-service 3.0.0-alpha.4 → 3.0.0-alpha.8

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?: {
@@ -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;
@@ -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;
@@ -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));
@@ -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;
@@ -258,7 +258,7 @@ function create(mode, getTsPluginClient) {
258
258
  ...propInfos,
259
259
  ...attrs.map(attr => ({ name: attr })),
260
260
  ]) {
261
- const isGlobal = !propsSet.has(prop.name);
261
+ const isGlobal = prop.isAttribute || !propsSet.has(prop.name);
262
262
  const name = casing.attr === types_1.AttrNameCasing.Camel ? prop.name : (0, language_core_1.hyphenateAttr)(prop.name);
263
263
  const isEvent = (0, language_core_1.hyphenateAttr)(name).startsWith('on-');
264
264
  if (isEvent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.8",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -17,14 +17,14 @@
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.4",
24
+ "@vue/language-core": "3.0.0-alpha.8",
25
25
  "@vue/shared": "^3.5.0",
26
- "@vue/typescript-plugin": "3.0.0-alpha.4",
27
- "alien-signals": "^1.0.3",
26
+ "@vue/typescript-plugin": "3.0.0-alpha.8",
27
+ "alien-signals": "^2.0.5",
28
28
  "path-browserify": "^1.0.1",
29
29
  "volar-service-css": "0.0.64",
30
30
  "volar-service-emmet": "0.0.64",
@@ -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": "1769cd6b94ec9e0cc2681b8dbba904f35856ba1c"
48
+ "gitHead": "d38cb93558fe8015c7ffe9ceacfdd3296e3692f6"
49
49
  }
@@ -1,2 +0,0 @@
1
- import type { LanguageServicePlugin } from '@volar/language-service';
2
- export declare function create(): LanguageServicePlugin;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = create;
4
- function create() {
5
- return {
6
- name: 'vue-autoinsert-selfClosing',
7
- capabilities: {
8
- autoInsertionProvider: {
9
- triggerCharacters: ['/'],
10
- configurationSections: ['vue.autoInsert.selfClosing'],
11
- },
12
- },
13
- create(context) {
14
- return {
15
- async provideAutoInsertSnippet(document, selection, change) {
16
- if (document.languageId !== 'html') {
17
- return;
18
- }
19
- const enabled = await context.env.getConfiguration?.('vue.autoInsert.selfClosing') ?? true;
20
- if (!enabled) {
21
- return;
22
- }
23
- if (change.text === '{}'
24
- && document.getText().slice(change.rangeOffset - 1, change.rangeOffset + 3) === '{{}}'
25
- && document.offsetAt(selection) === change.rangeOffset + 1) {
26
- return ` $0 `;
27
- }
28
- },
29
- };
30
- },
31
- };
32
- }
33
- //# sourceMappingURL=vue-autoinsert-self-closing.js.map