@vue/language-service 1.9.0-alpha.3 → 2.0.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.
Files changed (43) 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/package.json +18 -18
  8. package/out/helpers.d.ts +0 -17
  9. package/out/helpers.js +0 -235
  10. package/out/ideFeatures/dragImport.d.ts +0 -9
  11. package/out/ideFeatures/dragImport.js +0 -50
  12. package/out/ideFeatures/nameCasing.d.ts +0 -16
  13. package/out/ideFeatures/nameCasing.js +0 -158
  14. package/out/index.d.ts +0 -8
  15. package/out/index.js +0 -26
  16. package/out/languageService.d.ts +0 -9
  17. package/out/languageService.js +0 -239
  18. package/out/plugins/data.d.ts +0 -5
  19. package/out/plugins/data.js +0 -91
  20. package/out/plugins/vue-autoinsert-dotvalue.d.ts +0 -7
  21. package/out/plugins/vue-autoinsert-dotvalue.js +0 -161
  22. package/out/plugins/vue-autoinsert-parentheses.d.ts +0 -3
  23. package/out/plugins/vue-autoinsert-parentheses.js +0 -61
  24. package/out/plugins/vue-autoinsert-space.d.ts +0 -3
  25. package/out/plugins/vue-autoinsert-space.js +0 -32
  26. package/out/plugins/vue-codelens-references.d.ts +0 -3
  27. package/out/plugins/vue-codelens-references.js +0 -54
  28. package/out/plugins/vue-directive-comments.d.ts +0 -3
  29. package/out/plugins/vue-directive-comments.js +0 -57
  30. package/out/plugins/vue-extract-file.d.ts +0 -9
  31. package/out/plugins/vue-extract-file.js +0 -293
  32. package/out/plugins/vue-template.d.ts +0 -12
  33. package/out/plugins/vue-template.js +0 -548
  34. package/out/plugins/vue-toggle-v-bind-codeaction.d.ts +0 -3
  35. package/out/plugins/vue-toggle-v-bind-codeaction.js +0 -126
  36. package/out/plugins/vue-twoslash-queries.d.ts +0 -3
  37. package/out/plugins/vue-twoslash-queries.js +0 -60
  38. package/out/plugins/vue-visualize-hidden-callback-param.d.ts +0 -3
  39. package/out/plugins/vue-visualize-hidden-callback-param.js +0 -43
  40. package/out/plugins/vue.d.ts +0 -8
  41. package/out/plugins/vue.js +0 -169
  42. package/out/types.d.ts +0 -11
  43. package/out/types.js +0 -31
@@ -1,126 +0,0 @@
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
- const create = function () {
6
- return (ctx, modules) => {
7
- if (!modules?.typescript)
8
- return {};
9
- const ts = modules.typescript;
10
- return {
11
- provideCodeActions(document, range, _context) {
12
- const startOffset = document.offsetAt(range.start);
13
- const endOffset = document.offsetAt(range.end);
14
- const [vueFile] = ctx.documents.getVirtualFileByUri(document.uri);
15
- if (!vueFile || !(vueFile instanceof language_core_1.VueFile)) {
16
- return;
17
- }
18
- const { template } = vueFile.sfc;
19
- if (!template?.ast)
20
- return;
21
- const templateStartOffset = template.startTagEnd;
22
- const result = [];
23
- (0, language_core_1.walkElementNodes)(template.ast, node => {
24
- if (startOffset > templateStartOffset + node.loc.end.offset || endOffset < templateStartOffset + node.loc.start.offset) {
25
- return;
26
- }
27
- for (const prop of node.props) {
28
- if (startOffset - templateStartOffset >= prop.loc.start.offset
29
- && endOffset - templateStartOffset <= prop.loc.end.offset) {
30
- if (prop.type === 7 && prop.exp) {
31
- const sourceFile = ts.createSourceFile('/a.ts', prop.exp.loc.source, ts.ScriptTarget.Latest, true);
32
- const firstStatement = sourceFile.statements[0];
33
- if (sourceFile.statements.length === 1 && ts.isExpressionStatement(firstStatement) && ts.isStringLiteralLike(firstStatement.expression)) {
34
- const stringNode = sourceFile.statements[0];
35
- const removeTextRanges = [
36
- [prop.loc.start.offset, prop.loc.start.offset + 1],
37
- // Work correctly with trivias for cases like <input :type=" 'password' " />
38
- [prop.exp.loc.start.offset, prop.exp.loc.start.offset + stringNode.pos + stringNode.getLeadingTriviaWidth() + 1],
39
- [prop.exp.loc.start.offset + stringNode.end - 1, prop.exp.loc.end.offset],
40
- ];
41
- result.push({
42
- title: 'Remove v-bind from attribute',
43
- kind: 'refactor.rewrite.removeVBind',
44
- edit: {
45
- changes: {
46
- [document.uri]: removeTextRanges.map(range => ({
47
- newText: '',
48
- range: {
49
- start: document.positionAt(templateStartOffset + range[0]),
50
- end: document.positionAt(templateStartOffset + range[1]),
51
- }
52
- }))
53
- },
54
- },
55
- });
56
- }
57
- }
58
- if (prop.type === 6) {
59
- const edits = [];
60
- const addVBindPos = document.positionAt(templateStartOffset + prop.loc.start.offset);
61
- edits.push({
62
- newText: ':',
63
- range: {
64
- start: addVBindPos,
65
- end: addVBindPos,
66
- },
67
- });
68
- let newPosition;
69
- if (prop.value) {
70
- const valueStart = document.positionAt(templateStartOffset + prop.value.loc.start.offset);
71
- const valueEnd = document.positionAt(templateStartOffset + prop.value.loc.end.offset);
72
- if (prop.value.loc.end.offset - prop.value.loc.start.offset !== prop.value.content.length) {
73
- valueStart.character++;
74
- valueEnd.character--;
75
- }
76
- edits.push({
77
- newText: "'",
78
- range: {
79
- start: valueStart,
80
- end: valueStart,
81
- },
82
- });
83
- edits.push({
84
- newText: "'",
85
- range: {
86
- start: valueEnd,
87
- end: valueEnd,
88
- },
89
- });
90
- }
91
- else {
92
- const addValuePos = document.positionAt(templateStartOffset + prop.loc.end.offset);
93
- newPosition = {
94
- line: addValuePos.line,
95
- character: addValuePos.character + ':'.length + '="'.length,
96
- };
97
- edits.push({
98
- newText: '=""',
99
- range: {
100
- start: addValuePos,
101
- end: addValuePos
102
- },
103
- });
104
- }
105
- result.push({
106
- title: 'Add v-bind to attribute',
107
- kind: 'refactor.rewrite.addVBind',
108
- edit: {
109
- changes: { [document.uri]: edits },
110
- },
111
- command: newPosition ? ctx?.commands.setSelection.create(newPosition) : undefined,
112
- });
113
- }
114
- }
115
- }
116
- });
117
- return result;
118
- },
119
- transformCodeAction(item) {
120
- return item; // ignore mapping
121
- },
122
- };
123
- };
124
- };
125
- exports.create = create;
126
- //# sourceMappingURL=vue-toggle-v-bind-codeaction.js.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-twoslash-queries.d.ts.map
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const language_service_1 = require("@volar/language-service");
5
- const vue = require("@vue/language-core");
6
- const twoslashReg = /<!--\s*\^\?\s*-->/g;
7
- const plugin = (context, modules) => {
8
- if (!context || !modules?.typescript)
9
- return {};
10
- const ts = modules.typescript;
11
- return {
12
- provideInlayHints(document, range) {
13
- return worker(document.uri, (vueFile) => {
14
- const hoverOffsets = [];
15
- const inlayHints = [];
16
- const languageService = context.inject('typescript/languageService');
17
- for (const pointer of document.getText(range).matchAll(twoslashReg)) {
18
- const offset = pointer.index + pointer[0].indexOf('^?') + document.offsetAt(range.start);
19
- const position = document.positionAt(offset);
20
- hoverOffsets.push([position, document.offsetAt({
21
- line: position.line - 1,
22
- character: position.character,
23
- })]);
24
- }
25
- (0, language_service_1.forEachEmbeddedFile)(vueFile, (embedded) => {
26
- if (embedded.kind === language_service_1.FileKind.TypeScriptHostFile) {
27
- for (const [_, map] of context.documents.getMapsByVirtualFileName(embedded.fileName)) {
28
- for (const [pointerPosition, hoverOffset] of hoverOffsets) {
29
- for (const [tsOffset, mapping] of map.map.toGeneratedOffsets(hoverOffset)) {
30
- if (mapping.data.hover) {
31
- const quickInfo = languageService.getQuickInfoAtPosition(embedded.fileName, tsOffset);
32
- if (quickInfo) {
33
- inlayHints.push({
34
- position: { line: pointerPosition.line, character: pointerPosition.character + 2 },
35
- label: ts.displayPartsToString(quickInfo.displayParts),
36
- paddingLeft: true,
37
- paddingRight: false,
38
- });
39
- }
40
- break;
41
- }
42
- }
43
- }
44
- }
45
- }
46
- });
47
- return inlayHints;
48
- });
49
- },
50
- };
51
- function worker(uri, callback) {
52
- const [virtualFile] = context.documents.getVirtualFileByUri(uri);
53
- if (!(virtualFile instanceof vue.VueFile))
54
- return;
55
- return callback(virtualFile);
56
- }
57
- };
58
- const create = () => plugin;
59
- exports.create = create;
60
- //# sourceMappingURL=vue-twoslash-queries.js.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-visualize-hidden-callback-param.d.ts.map
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const plugin = (context) => {
5
- if (!context)
6
- return {};
7
- return {
8
- async provideInlayHints(document, range) {
9
- const settings = {};
10
- const result = [];
11
- const [file] = context.documents.getVirtualFileByUri(document.uri);
12
- if (file) {
13
- const start = document.offsetAt(range.start);
14
- const end = document.offsetAt(range.end);
15
- for (const mapping of file.mappings) {
16
- const hint = mapping.data.__hint;
17
- if (mapping.generatedRange[0] >= start
18
- && mapping.generatedRange[1] <= end
19
- && hint) {
20
- settings[hint.setting] ??= await context.env.getConfiguration?.(hint.setting) ?? false;
21
- if (!settings[hint.setting])
22
- continue;
23
- result.push({
24
- label: hint.label,
25
- paddingRight: hint.paddingRight,
26
- paddingLeft: hint.paddingLeft,
27
- position: document.positionAt(mapping.generatedRange[0]),
28
- kind: 2,
29
- tooltip: {
30
- kind: 'markdown',
31
- value: hint.tooltip,
32
- },
33
- });
34
- }
35
- }
36
- }
37
- return result;
38
- },
39
- };
40
- };
41
- const create = () => plugin;
42
- exports.create = create;
43
- //# sourceMappingURL=vue-visualize-hidden-callback-param.js.map
@@ -1,8 +0,0 @@
1
- import type { Service } from '@volar/language-service';
2
- import { TextDocument } from 'vscode-languageserver-textdocument';
3
- import * as vue from '@vue/language-core';
4
- export interface Provide {
5
- 'vue/vueFile': (document: TextDocument) => vue.VueFile | undefined;
6
- }
7
- export declare const create: () => Service<Provide>;
8
- //# sourceMappingURL=vue.d.ts.map
@@ -1,169 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const html = require("vscode-html-languageservice");
5
- const volar_service_html_1 = require("volar-service-html");
6
- const vue = require("@vue/language-core");
7
- const data_1 = require("./data");
8
- let sfcDataProvider;
9
- const create = () => (context, modules) => {
10
- const htmlPlugin = (0, volar_service_html_1.default)({ languageId: 'vue', useCustomDataProviders: false })(context, modules);
11
- if (!context)
12
- return htmlPlugin;
13
- sfcDataProvider ??= html.newHTMLDataProvider('vue', (0, data_1.loadLanguageBlocks)(context.env.locale ?? 'en'));
14
- htmlPlugin.provide['html/languageService']().setDataProviders(false, [sfcDataProvider]);
15
- return {
16
- ...htmlPlugin,
17
- provide: {
18
- 'vue/vueFile': document => {
19
- return worker(document, (vueFile) => {
20
- return vueFile;
21
- });
22
- },
23
- },
24
- provideSemanticDiagnostics(document) {
25
- return worker(document, (vueSourceFile) => {
26
- const result = [];
27
- const sfc = vueSourceFile.sfc;
28
- const program = context.inject('typescript/languageService').getProgram();
29
- if (program && !program.getSourceFile(vueSourceFile.mainScriptName)) {
30
- for (const script of [sfc.script, sfc.scriptSetup]) {
31
- if (!script || script.content === '')
32
- continue;
33
- const error = {
34
- range: {
35
- start: document.positionAt(script.start),
36
- end: document.positionAt(script.startTagEnd),
37
- },
38
- message: `Virtual script ${JSON.stringify(vueSourceFile.mainScriptName)} not found, may missing <script lang="ts"> / "allowJs": true / jsconfig.json.`,
39
- severity: 3,
40
- source: 'vue',
41
- };
42
- result.push(error);
43
- }
44
- }
45
- return result;
46
- });
47
- },
48
- provideDocumentLinks: undefined,
49
- provideDocumentSymbols(document) {
50
- return worker(document, (vueSourceFile) => {
51
- const result = [];
52
- const descriptor = vueSourceFile.sfc;
53
- if (descriptor.template) {
54
- result.push({
55
- name: 'template',
56
- kind: 2,
57
- range: {
58
- start: document.positionAt(descriptor.template.start),
59
- end: document.positionAt(descriptor.template.end),
60
- },
61
- selectionRange: {
62
- start: document.positionAt(descriptor.template.start),
63
- end: document.positionAt(descriptor.template.startTagEnd),
64
- },
65
- });
66
- }
67
- if (descriptor.script) {
68
- result.push({
69
- name: 'script',
70
- kind: 2,
71
- range: {
72
- start: document.positionAt(descriptor.script.start),
73
- end: document.positionAt(descriptor.script.end),
74
- },
75
- selectionRange: {
76
- start: document.positionAt(descriptor.script.start),
77
- end: document.positionAt(descriptor.script.startTagEnd),
78
- },
79
- });
80
- }
81
- if (descriptor.scriptSetup) {
82
- result.push({
83
- name: 'script setup',
84
- kind: 2,
85
- range: {
86
- start: document.positionAt(descriptor.scriptSetup.start),
87
- end: document.positionAt(descriptor.scriptSetup.end),
88
- },
89
- selectionRange: {
90
- start: document.positionAt(descriptor.scriptSetup.start),
91
- end: document.positionAt(descriptor.scriptSetup.startTagEnd),
92
- },
93
- });
94
- }
95
- for (const style of descriptor.styles) {
96
- let name = 'style';
97
- if (style.scoped)
98
- name += ' scoped';
99
- if (style.module)
100
- name += ' module';
101
- result.push({
102
- name,
103
- kind: 2,
104
- range: {
105
- start: document.positionAt(style.start),
106
- end: document.positionAt(style.end),
107
- },
108
- selectionRange: {
109
- start: document.positionAt(style.start),
110
- end: document.positionAt(style.startTagEnd),
111
- },
112
- });
113
- }
114
- for (const customBlock of descriptor.customBlocks) {
115
- result.push({
116
- name: `${customBlock.type}`,
117
- kind: 2,
118
- range: {
119
- start: document.positionAt(customBlock.start),
120
- end: document.positionAt(customBlock.end),
121
- },
122
- selectionRange: {
123
- start: document.positionAt(customBlock.start),
124
- end: document.positionAt(customBlock.startTagEnd),
125
- },
126
- });
127
- }
128
- return result;
129
- });
130
- },
131
- provideDocumentFormattingEdits(document) {
132
- return worker(document, (vueSourceFile) => {
133
- const blocks = [
134
- vueSourceFile.sfc.script,
135
- vueSourceFile.sfc.scriptSetup,
136
- vueSourceFile.sfc.template,
137
- ...vueSourceFile.sfc.styles,
138
- ...vueSourceFile.sfc.customBlocks,
139
- ].filter((block) => !!block)
140
- .sort((a, b) => b.start - a.start);
141
- const edits = [];
142
- for (const block of blocks) {
143
- const startPos = document.positionAt(block.start);
144
- if (startPos.character !== 0) {
145
- edits.push({
146
- range: {
147
- start: {
148
- line: startPos.line,
149
- character: 0,
150
- },
151
- end: startPos,
152
- },
153
- newText: '',
154
- });
155
- }
156
- }
157
- return edits;
158
- });
159
- },
160
- };
161
- function worker(document, callback) {
162
- const [vueFile] = context.documents.getVirtualFileByUri(document.uri);
163
- if (vueFile instanceof vue.VueFile) {
164
- return callback(vueFile);
165
- }
166
- }
167
- };
168
- exports.create = create;
169
- //# sourceMappingURL=vue.js.map
package/out/types.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export declare enum TagNameCasing {
2
- Kebab = 0,
3
- Pascal = 1
4
- }
5
- export declare enum AttrNameCasing {
6
- Kebab = 0,
7
- Camel = 1
8
- }
9
- export * from '@volar/language-service/lib/types';
10
- export * from '@vue/language-core/out/types';
11
- //# sourceMappingURL=types.d.ts.map
package/out/types.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AttrNameCasing = exports.TagNameCasing = void 0;
18
- var TagNameCasing;
19
- (function (TagNameCasing) {
20
- TagNameCasing[TagNameCasing["Kebab"] = 0] = "Kebab";
21
- TagNameCasing[TagNameCasing["Pascal"] = 1] = "Pascal";
22
- })(TagNameCasing || (exports.TagNameCasing = TagNameCasing = {}));
23
- var AttrNameCasing;
24
- (function (AttrNameCasing) {
25
- AttrNameCasing[AttrNameCasing["Kebab"] = 0] = "Kebab";
26
- AttrNameCasing[AttrNameCasing["Camel"] = 1] = "Camel";
27
- })(AttrNameCasing || (exports.AttrNameCasing = AttrNameCasing = {}));
28
- // only export types of depend packages
29
- __exportStar(require("@volar/language-service/lib/types"), exports);
30
- __exportStar(require("@vue/language-core/out/types"), exports);
31
- //# sourceMappingURL=types.js.map