@vue/language-service 1.9.0-alpha.3 → 2.0.1

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.
Files changed (72) hide show
  1. package/data/template/en.json +2 -2
  2. package/data/template/fr.json +1 -1
  3. package/data/template/ja.json +2 -2
  4. package/data/template/ko.json +13 -13
  5. package/data/template/pt.json +18 -18
  6. package/data/template/zh-cn.json +2 -2
  7. package/index.d.ts +7 -0
  8. package/index.js +64 -0
  9. package/lib/ideFeatures/nameCasing.d.ts +13 -0
  10. package/{out → lib}/ideFeatures/nameCasing.js +82 -29
  11. package/lib/plugins/css.d.ts +2 -0
  12. package/lib/plugins/css.js +27 -0
  13. package/{out → lib}/plugins/data.d.ts +1 -2
  14. package/lib/plugins/vue-autoinsert-dotvalue.d.ts +10 -0
  15. package/{out → lib}/plugins/vue-autoinsert-dotvalue.js +70 -54
  16. package/lib/plugins/vue-autoinsert-parentheses.d.ts +2 -0
  17. package/lib/plugins/vue-autoinsert-parentheses.js +60 -0
  18. package/lib/plugins/vue-autoinsert-space.d.ts +2 -0
  19. package/lib/plugins/vue-autoinsert-space.js +34 -0
  20. package/lib/plugins/vue-codelens-references.d.ts +2 -0
  21. package/lib/plugins/vue-codelens-references.js +38 -0
  22. package/lib/plugins/vue-directive-comments.d.ts +2 -0
  23. package/lib/plugins/vue-directive-comments.js +61 -0
  24. package/lib/plugins/vue-document-drop.d.ts +2 -0
  25. package/lib/plugins/vue-document-drop.js +81 -0
  26. package/lib/plugins/vue-extract-file.d.ts +8 -0
  27. package/lib/plugins/vue-extract-file.js +258 -0
  28. package/lib/plugins/vue-sfc.d.ts +7 -0
  29. package/lib/plugins/vue-sfc.js +163 -0
  30. package/lib/plugins/vue-template.d.ts +3 -0
  31. package/lib/plugins/vue-template.js +594 -0
  32. package/lib/plugins/vue-toggle-v-bind-codeaction.d.ts +2 -0
  33. package/lib/plugins/vue-toggle-v-bind-codeaction.js +126 -0
  34. package/lib/plugins/vue-twoslash-queries.d.ts +2 -0
  35. package/lib/plugins/vue-twoslash-queries.js +50 -0
  36. package/lib/plugins/vue-visualize-hidden-callback-param.d.ts +2 -0
  37. package/lib/plugins/vue-visualize-hidden-callback-param.js +45 -0
  38. package/{out → lib}/types.d.ts +1 -2
  39. package/{out → lib}/types.js +1 -1
  40. package/package.json +20 -20
  41. package/scripts/update-html-data.js +426 -0
  42. package/out/helpers.d.ts +0 -17
  43. package/out/helpers.js +0 -235
  44. package/out/ideFeatures/dragImport.d.ts +0 -9
  45. package/out/ideFeatures/dragImport.js +0 -50
  46. package/out/ideFeatures/nameCasing.d.ts +0 -16
  47. package/out/index.d.ts +0 -8
  48. package/out/index.js +0 -26
  49. package/out/languageService.d.ts +0 -9
  50. package/out/languageService.js +0 -239
  51. package/out/plugins/vue-autoinsert-dotvalue.d.ts +0 -7
  52. package/out/plugins/vue-autoinsert-parentheses.d.ts +0 -3
  53. package/out/plugins/vue-autoinsert-parentheses.js +0 -61
  54. package/out/plugins/vue-autoinsert-space.d.ts +0 -3
  55. package/out/plugins/vue-autoinsert-space.js +0 -32
  56. package/out/plugins/vue-codelens-references.d.ts +0 -3
  57. package/out/plugins/vue-codelens-references.js +0 -54
  58. package/out/plugins/vue-directive-comments.d.ts +0 -3
  59. package/out/plugins/vue-directive-comments.js +0 -57
  60. package/out/plugins/vue-extract-file.d.ts +0 -9
  61. package/out/plugins/vue-extract-file.js +0 -293
  62. package/out/plugins/vue-template.d.ts +0 -12
  63. package/out/plugins/vue-template.js +0 -548
  64. package/out/plugins/vue-toggle-v-bind-codeaction.d.ts +0 -3
  65. package/out/plugins/vue-toggle-v-bind-codeaction.js +0 -126
  66. package/out/plugins/vue-twoslash-queries.d.ts +0 -3
  67. package/out/plugins/vue-twoslash-queries.js +0 -60
  68. package/out/plugins/vue-visualize-hidden-callback-param.d.ts +0 -3
  69. package/out/plugins/vue-visualize-hidden-callback-param.js +0 -43
  70. package/out/plugins/vue.d.ts +0 -8
  71. package/out/plugins/vue.js +0 -169
  72. /package/{out → lib}/plugins/data.js +0 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const language_core_1 = require("@vue/language-core");
5
+ function create(ts) {
6
+ return {
7
+ name: 'vue-toggle-v-bind-codeaction',
8
+ create(context) {
9
+ return {
10
+ provideCodeActions(document, range, _context) {
11
+ const startOffset = document.offsetAt(range.start);
12
+ const endOffset = document.offsetAt(range.end);
13
+ const [virtualCode] = context.documents.getVirtualCodeByUri(document.uri);
14
+ if (!(virtualCode instanceof language_core_1.VueGeneratedCode)) {
15
+ return;
16
+ }
17
+ const { template } = virtualCode.sfc;
18
+ if (!template?.ast)
19
+ return;
20
+ const templateStartOffset = template.startTagEnd;
21
+ const result = [];
22
+ for (const node of (0, language_core_1.eachElementNode)(template.ast)) {
23
+ if (startOffset > templateStartOffset + node.loc.end.offset || endOffset < templateStartOffset + node.loc.start.offset) {
24
+ return;
25
+ }
26
+ for (const prop of node.props) {
27
+ if (startOffset - templateStartOffset >= prop.loc.start.offset
28
+ && endOffset - templateStartOffset <= prop.loc.end.offset) {
29
+ if (prop.type === 7 && prop.exp) {
30
+ const sourceFile = ts.createSourceFile('/a.ts', prop.exp.loc.source, ts.ScriptTarget.Latest, true);
31
+ const firstStatement = sourceFile.statements[0];
32
+ if (sourceFile.statements.length === 1 && ts.isExpressionStatement(firstStatement) && ts.isStringLiteralLike(firstStatement.expression)) {
33
+ const stringNode = sourceFile.statements[0];
34
+ const removeTextRanges = [
35
+ [prop.loc.start.offset, prop.loc.start.offset + 1],
36
+ // Work correctly with trivias for cases like <input :type=" 'password' " />
37
+ [prop.exp.loc.start.offset, prop.exp.loc.start.offset + stringNode.pos + stringNode.getLeadingTriviaWidth() + 1],
38
+ [prop.exp.loc.start.offset + stringNode.end - 1, prop.exp.loc.end.offset],
39
+ ];
40
+ result.push({
41
+ title: 'Remove v-bind from attribute',
42
+ kind: 'refactor.rewrite.removeVBind',
43
+ edit: {
44
+ changes: {
45
+ [document.uri]: removeTextRanges.map(range => ({
46
+ newText: '',
47
+ range: {
48
+ start: document.positionAt(templateStartOffset + range[0]),
49
+ end: document.positionAt(templateStartOffset + range[1]),
50
+ }
51
+ }))
52
+ },
53
+ },
54
+ });
55
+ }
56
+ }
57
+ if (prop.type === 6) {
58
+ const edits = [];
59
+ const addVBindPos = document.positionAt(templateStartOffset + prop.loc.start.offset);
60
+ edits.push({
61
+ newText: ':',
62
+ range: {
63
+ start: addVBindPos,
64
+ end: addVBindPos,
65
+ },
66
+ });
67
+ let newPosition;
68
+ if (prop.value) {
69
+ const valueStart = document.positionAt(templateStartOffset + prop.value.loc.start.offset);
70
+ const valueEnd = document.positionAt(templateStartOffset + prop.value.loc.end.offset);
71
+ if (prop.value.loc.end.offset - prop.value.loc.start.offset !== prop.value.content.length) {
72
+ valueStart.character++;
73
+ valueEnd.character--;
74
+ }
75
+ edits.push({
76
+ newText: "'",
77
+ range: {
78
+ start: valueStart,
79
+ end: valueStart,
80
+ },
81
+ });
82
+ edits.push({
83
+ newText: "'",
84
+ range: {
85
+ start: valueEnd,
86
+ end: valueEnd,
87
+ },
88
+ });
89
+ }
90
+ else {
91
+ const addValuePos = document.positionAt(templateStartOffset + prop.loc.end.offset);
92
+ newPosition = {
93
+ line: addValuePos.line,
94
+ character: addValuePos.character + ':'.length + '="'.length,
95
+ };
96
+ edits.push({
97
+ newText: '=""',
98
+ range: {
99
+ start: addValuePos,
100
+ end: addValuePos
101
+ },
102
+ });
103
+ }
104
+ result.push({
105
+ title: 'Add v-bind to attribute',
106
+ kind: 'refactor.rewrite.addVBind',
107
+ edit: {
108
+ changes: { [document.uri]: edits },
109
+ },
110
+ command: newPosition ? context?.commands.setSelection.create(newPosition) : undefined,
111
+ });
112
+ }
113
+ }
114
+ }
115
+ }
116
+ return result;
117
+ },
118
+ transformCodeAction(item) {
119
+ return item; // ignore mapping
120
+ },
121
+ };
122
+ },
123
+ };
124
+ }
125
+ exports.create = create;
126
+ //# sourceMappingURL=vue-toggle-v-bind-codeaction.js.map
@@ -0,0 +1,2 @@
1
+ import type { ServicePlugin } from '@volar/language-service';
2
+ export declare function create(ts: typeof import('typescript')): ServicePlugin;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const vue = require("@vue/language-core");
5
+ const client_1 = require("@vue/typescript-plugin/lib/client");
6
+ const twoslashReg = /<!--\s*\^\?\s*-->/g;
7
+ function create(ts) {
8
+ return {
9
+ name: 'vue-twoslash-queries',
10
+ create(context) {
11
+ return {
12
+ async provideInlayHints(document, range) {
13
+ const [virtualCode, sourceFile] = context.documents.getVirtualCodeByUri(document.uri);
14
+ if (!(sourceFile?.generated?.code instanceof vue.VueGeneratedCode) || virtualCode?.id !== 'template')
15
+ return;
16
+ const hoverOffsets = [];
17
+ const inlayHints = [];
18
+ for (const pointer of document.getText(range).matchAll(twoslashReg)) {
19
+ const offset = pointer.index + pointer[0].indexOf('^?') + document.offsetAt(range.start);
20
+ const position = document.positionAt(offset);
21
+ hoverOffsets.push([position, document.offsetAt({
22
+ line: position.line - 1,
23
+ character: position.character,
24
+ })]);
25
+ }
26
+ for (const [pointerPosition, hoverOffset] of hoverOffsets) {
27
+ for (const [_1, [_2, map]] of context.language.files.getMaps(virtualCode)) {
28
+ for (const [sourceOffset] of map.getSourceOffsets(hoverOffset)) {
29
+ const quickInfo = await (0, client_1.getQuickInfoAtPosition)(sourceFile.generated.code.fileName, sourceOffset);
30
+ if (quickInfo) {
31
+ inlayHints.push({
32
+ position: { line: pointerPosition.line, character: pointerPosition.character + 2 },
33
+ label: ts.displayPartsToString(quickInfo.displayParts),
34
+ paddingLeft: true,
35
+ paddingRight: false,
36
+ });
37
+ break;
38
+ }
39
+ }
40
+ break;
41
+ }
42
+ }
43
+ return inlayHints;
44
+ },
45
+ };
46
+ },
47
+ };
48
+ }
49
+ exports.create = create;
50
+ //# sourceMappingURL=vue-twoslash-queries.js.map
@@ -0,0 +1,2 @@
1
+ import type { ServicePlugin } from '../types';
2
+ export declare function create(): ServicePlugin;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ function create() {
5
+ return {
6
+ name: 'vue-inlay-hints-hidden-callback-param',
7
+ create(context) {
8
+ return {
9
+ async provideInlayHints(document, range) {
10
+ const settings = {};
11
+ const result = [];
12
+ const [vitualFile] = context.documents.getVirtualCodeByUri(document.uri);
13
+ if (vitualFile) {
14
+ const start = document.offsetAt(range.start);
15
+ const end = document.offsetAt(range.end);
16
+ for (const mapping of vitualFile.mappings) {
17
+ const hint = mapping.data.__hint;
18
+ if (mapping.generatedOffsets[0] >= start
19
+ && mapping.generatedOffsets[mapping.generatedOffsets.length - 1] + mapping.lengths[mapping.lengths.length - 1] <= end
20
+ && hint) {
21
+ settings[hint.setting] ??= await context.env.getConfiguration?.(hint.setting) ?? false;
22
+ if (!settings[hint.setting])
23
+ continue;
24
+ result.push({
25
+ label: hint.label,
26
+ paddingRight: hint.paddingRight,
27
+ paddingLeft: hint.paddingLeft,
28
+ position: document.positionAt(mapping.generatedOffsets[0]),
29
+ kind: 2,
30
+ tooltip: {
31
+ kind: 'markdown',
32
+ value: hint.tooltip,
33
+ },
34
+ });
35
+ }
36
+ }
37
+ }
38
+ return result;
39
+ },
40
+ };
41
+ },
42
+ };
43
+ }
44
+ exports.create = create;
45
+ //# sourceMappingURL=vue-visualize-hidden-callback-param.js.map
@@ -7,5 +7,4 @@ export declare enum AttrNameCasing {
7
7
  Camel = 1
8
8
  }
9
9
  export * from '@volar/language-service/lib/types';
10
- export * from '@vue/language-core/out/types';
11
- //# sourceMappingURL=types.d.ts.map
10
+ export * from '@vue/language-core/lib/types';
@@ -27,5 +27,5 @@ var AttrNameCasing;
27
27
  })(AttrNameCasing || (exports.AttrNameCasing = AttrNameCasing = {}));
28
28
  // only export types of depend packages
29
29
  __exportStar(require("@volar/language-service/lib/types"), exports);
30
- __exportStar(require("@vue/language-core/out/types"), exports);
30
+ __exportStar(require("@vue/language-core/lib/types"), exports);
31
31
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "1.9.0-alpha.3",
4
- "main": "out/index.js",
3
+ "version": "2.0.1",
5
4
  "license": "MIT",
6
5
  "files": [
7
6
  "data",
8
- "out/**/*.js",
9
- "out/**/*.d.ts"
7
+ "**/*.js",
8
+ "**/*.d.ts"
10
9
  ],
11
10
  "repository": {
12
11
  "type": "git",
@@ -17,31 +16,32 @@
17
16
  "update-html-data": "node ./scripts/update-html-data.js"
18
17
  },
19
18
  "dependencies": {
20
- "@volar/language-core": "~1.11.0",
21
- "@volar/language-service": "~1.11.0",
22
- "@volar/typescript": "~1.11.0",
23
- "@vue/compiler-dom": "^3.3.0",
24
- "@vue/language-core": "1.9.0-alpha.3",
25
- "@vue/shared": "^3.3.0",
19
+ "@volar/language-core": "~2.1.0",
20
+ "@volar/language-service": "~2.1.0",
21
+ "@volar/typescript": "~2.1.0",
22
+ "@vue/compiler-dom": "^3.4.0",
23
+ "@vue/language-core": "2.0.1",
24
+ "@vue/shared": "^3.4.0",
25
+ "@vue/typescript-plugin": "2.0.1",
26
26
  "computeds": "^0.0.1",
27
27
  "path-browserify": "^1.0.1",
28
- "volar-service-css": "0.0.17",
29
- "volar-service-emmet": "0.0.17",
30
- "volar-service-html": "0.0.17",
31
- "volar-service-json": "0.0.17",
32
- "volar-service-pug": "0.0.17",
33
- "volar-service-pug-beautify": "0.0.17",
34
- "volar-service-typescript": "0.0.17",
35
- "volar-service-typescript-twoslash-queries": "0.0.17",
28
+ "volar-service-css": "0.0.31",
29
+ "volar-service-emmet": "0.0.31",
30
+ "volar-service-html": "0.0.31",
31
+ "volar-service-json": "0.0.31",
32
+ "volar-service-pug": "0.0.31",
33
+ "volar-service-pug-beautify": "0.0.31",
34
+ "volar-service-typescript": "0.0.31",
35
+ "volar-service-typescript-twoslash-queries": "0.0.31",
36
36
  "vscode-html-languageservice": "^5.1.0",
37
37
  "vscode-languageserver-textdocument": "^1.0.11"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "latest",
41
41
  "@types/path-browserify": "latest",
42
- "@volar/kit": "~1.11.0",
42
+ "@volar/kit": "~2.1.0",
43
43
  "vscode-languageserver-protocol": "^3.17.5",
44
44
  "vscode-uri": "^3.0.8"
45
45
  },
46
- "gitHead": "cf6564bc8c649151c2e72a93d0aa482d4a59a773"
46
+ "gitHead": "adedfd0983c910370d080e955702cca7d2275420"
47
47
  }