@vue/language-service 1.7.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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/data/language-blocks/en.json +626 -0
  3. package/data/language-blocks/fr.json +626 -0
  4. package/data/language-blocks/ja.json +626 -0
  5. package/data/language-blocks/ko.json +626 -0
  6. package/data/language-blocks/zh-cn.json +626 -0
  7. package/data/language-blocks/zh-tw.json +626 -0
  8. package/data/model-modifiers/en.json +104 -0
  9. package/data/model-modifiers/fr.json +104 -0
  10. package/data/model-modifiers/ja.json +104 -0
  11. package/data/model-modifiers/ko.json +104 -0
  12. package/data/model-modifiers/zh-cn.json +104 -0
  13. package/data/model-modifiers/zh-tw.json +104 -0
  14. package/data/template/en.json +866 -0
  15. package/data/template/fr.json +866 -0
  16. package/data/template/ja.json +866 -0
  17. package/data/template/ko.json +866 -0
  18. package/data/template/zh-cn.json +866 -0
  19. package/data/template/zh-tw.json +866 -0
  20. package/out/helpers.d.ts +15 -0
  21. package/out/helpers.js +246 -0
  22. package/out/ideFeatures/nameCasing.d.ts +13 -0
  23. package/out/ideFeatures/nameCasing.js +173 -0
  24. package/out/index.d.ts +5 -0
  25. package/out/index.js +24 -0
  26. package/out/languageService.d.ts +9 -0
  27. package/out/languageService.js +243 -0
  28. package/out/plugins/data.d.ts +4 -0
  29. package/out/plugins/data.js +90 -0
  30. package/out/plugins/vue-autoinsert-dotvalue.d.ts +7 -0
  31. package/out/plugins/vue-autoinsert-dotvalue.js +157 -0
  32. package/out/plugins/vue-autoinsert-parentheses.d.ts +3 -0
  33. package/out/plugins/vue-autoinsert-parentheses.js +67 -0
  34. package/out/plugins/vue-autoinsert-space.d.ts +3 -0
  35. package/out/plugins/vue-autoinsert-space.js +30 -0
  36. package/out/plugins/vue-codelens-references.d.ts +2 -0
  37. package/out/plugins/vue-codelens-references.js +53 -0
  38. package/out/plugins/vue-template.d.ts +10 -0
  39. package/out/plugins/vue-template.js +538 -0
  40. package/out/plugins/vue-twoslash-queries.d.ts +3 -0
  41. package/out/plugins/vue-twoslash-queries.js +59 -0
  42. package/out/plugins/vue-visualize-hidden-callback-param.d.ts +3 -0
  43. package/out/plugins/vue-visualize-hidden-callback-param.js +42 -0
  44. package/out/plugins/vue.d.ts +8 -0
  45. package/out/plugins/vue.js +137 -0
  46. package/out/types.d.ts +10 -0
  47. package/out/types.js +31 -0
  48. package/package.json +44 -0
@@ -0,0 +1,3 @@
1
+ import { Service } from '@volar/language-service';
2
+ declare const _default: () => Service;
3
+ export default _default;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vscode = require("vscode-languageserver-protocol");
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: vscode.InlayHintKind.Parameter,
29
+ tooltip: {
30
+ kind: 'markdown',
31
+ value: hint.tooltip,
32
+ },
33
+ });
34
+ }
35
+ }
36
+ }
37
+ return result;
38
+ },
39
+ };
40
+ };
41
+ exports.default = () => plugin;
42
+ //# sourceMappingURL=vue-visualize-hidden-callback-param.js.map
@@ -0,0 +1,8 @@
1
+ import { InjectionKey, Service } from '@volar/language-service';
2
+ import { TextDocument } from 'vscode-languageserver-textdocument';
3
+ import * as vue from '@vue/language-core';
4
+ export declare const injectionKeys: {
5
+ vueFile: InjectionKey<[TextDocument], vue.VueFile>;
6
+ };
7
+ declare const _default: () => Service;
8
+ export default _default;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectionKeys = void 0;
4
+ const language_service_1 = require("@volar/language-service");
5
+ const html = require("vscode-html-languageservice");
6
+ const vscode = require("vscode-languageserver-protocol");
7
+ const volar_service_html_1 = require("volar-service-html");
8
+ const vue = require("@vue/language-core");
9
+ const data_1 = require("./data");
10
+ let sfcDataProvider;
11
+ exports.injectionKeys = {
12
+ vueFile: 'vue/vueFile',
13
+ };
14
+ exports.default = () => (context) => {
15
+ const htmlPlugin = (0, volar_service_html_1.default)({ validLang: 'vue', disableCustomData: true })(context);
16
+ if (!context?.typescript)
17
+ return htmlPlugin;
18
+ sfcDataProvider ??= html.newHTMLDataProvider('vue', (0, data_1.loadLanguageBlocks)(context.env.locale ?? 'en'));
19
+ htmlPlugin.getHtmlLs().setDataProviders(false, [sfcDataProvider]);
20
+ const _ts = context.typescript;
21
+ return {
22
+ provide: (0, language_service_1.defineProvide)(exports.injectionKeys.vueFile, document => {
23
+ return worker(document, (vueFile) => {
24
+ return vueFile;
25
+ });
26
+ }),
27
+ ...htmlPlugin,
28
+ provideSemanticDiagnostics(document) {
29
+ return worker(document, (vueSourceFile) => {
30
+ const result = [];
31
+ const sfc = vueSourceFile.sfc;
32
+ const program = _ts.languageService.getProgram();
33
+ if (program && !program.getSourceFile(vueSourceFile.mainScriptName)) {
34
+ for (const script of [sfc.script, sfc.scriptSetup]) {
35
+ if (!script || script.content === '')
36
+ continue;
37
+ const error = vscode.Diagnostic.create({
38
+ start: document.positionAt(script.start),
39
+ end: document.positionAt(script.startTagEnd),
40
+ }, `Virtual script ${JSON.stringify(vueSourceFile.mainScriptName)} not found, may missing <script lang="ts"> / "allowJs": true / jsconfig.json.`, vscode.DiagnosticSeverity.Information, undefined, 'volar');
41
+ result.push(error);
42
+ }
43
+ }
44
+ return result;
45
+ });
46
+ },
47
+ findDocumentLinks: undefined,
48
+ provideDocumentSymbols(document) {
49
+ return worker(document, (vueSourceFile) => {
50
+ const result = [];
51
+ const descriptor = vueSourceFile.sfc;
52
+ if (descriptor.template) {
53
+ result.push({
54
+ name: 'template',
55
+ kind: vscode.SymbolKind.Module,
56
+ range: vscode.Range.create(document.positionAt(descriptor.template.start), document.positionAt(descriptor.template.end)),
57
+ selectionRange: vscode.Range.create(document.positionAt(descriptor.template.start), document.positionAt(descriptor.template.startTagEnd)),
58
+ });
59
+ }
60
+ if (descriptor.script) {
61
+ result.push({
62
+ name: 'script',
63
+ kind: vscode.SymbolKind.Module,
64
+ range: vscode.Range.create(document.positionAt(descriptor.script.start), document.positionAt(descriptor.script.end)),
65
+ selectionRange: vscode.Range.create(document.positionAt(descriptor.script.start), document.positionAt(descriptor.script.startTagEnd)),
66
+ });
67
+ }
68
+ if (descriptor.scriptSetup) {
69
+ result.push({
70
+ name: 'script setup',
71
+ kind: vscode.SymbolKind.Module,
72
+ range: vscode.Range.create(document.positionAt(descriptor.scriptSetup.start), document.positionAt(descriptor.scriptSetup.end)),
73
+ selectionRange: vscode.Range.create(document.positionAt(descriptor.scriptSetup.start), document.positionAt(descriptor.scriptSetup.startTagEnd)),
74
+ });
75
+ }
76
+ for (const style of descriptor.styles) {
77
+ let name = 'style';
78
+ if (style.scoped)
79
+ name += ' scoped';
80
+ if (style.module)
81
+ name += ' module';
82
+ result.push({
83
+ name,
84
+ kind: vscode.SymbolKind.Module,
85
+ range: vscode.Range.create(document.positionAt(style.start), document.positionAt(style.end)),
86
+ selectionRange: vscode.Range.create(document.positionAt(style.start), document.positionAt(style.startTagEnd)),
87
+ });
88
+ }
89
+ for (const customBlock of descriptor.customBlocks) {
90
+ result.push({
91
+ name: `${customBlock.type}`,
92
+ kind: vscode.SymbolKind.Module,
93
+ range: vscode.Range.create(document.positionAt(customBlock.start), document.positionAt(customBlock.end)),
94
+ selectionRange: vscode.Range.create(document.positionAt(customBlock.start), document.positionAt(customBlock.startTagEnd)),
95
+ });
96
+ }
97
+ return result;
98
+ });
99
+ },
100
+ provideDocumentFormattingEdits(document) {
101
+ return worker(document, (vueSourceFile) => {
102
+ const blocks = [
103
+ vueSourceFile.sfc.script,
104
+ vueSourceFile.sfc.scriptSetup,
105
+ vueSourceFile.sfc.template,
106
+ ...vueSourceFile.sfc.styles,
107
+ ...vueSourceFile.sfc.customBlocks,
108
+ ].filter((block) => !!block)
109
+ .sort((a, b) => b.start - a.start);
110
+ const edits = [];
111
+ for (const block of blocks) {
112
+ const startPos = document.positionAt(block.start);
113
+ if (startPos.character !== 0) {
114
+ edits.push({
115
+ range: {
116
+ start: {
117
+ line: startPos.line,
118
+ character: 0,
119
+ },
120
+ end: startPos,
121
+ },
122
+ newText: '',
123
+ });
124
+ }
125
+ }
126
+ return edits;
127
+ });
128
+ },
129
+ };
130
+ function worker(document, callback) {
131
+ const [vueFile] = context.documents.getVirtualFileByUri(document.uri);
132
+ if (vueFile instanceof vue.VueFile) {
133
+ return callback(vueFile);
134
+ }
135
+ }
136
+ };
137
+ //# sourceMappingURL=vue.js.map
package/out/types.d.ts ADDED
@@ -0,0 +1,10 @@
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/out/types';
10
+ export * from '@vue/language-core/out/types';
package/out/types.js ADDED
@@ -0,0 +1,31 @@
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 || (exports.TagNameCasing = {}));
23
+ var AttrNameCasing;
24
+ (function (AttrNameCasing) {
25
+ AttrNameCasing[AttrNameCasing["Kebab"] = 0] = "Kebab";
26
+ AttrNameCasing[AttrNameCasing["Camel"] = 1] = "Camel";
27
+ })(AttrNameCasing = exports.AttrNameCasing || (exports.AttrNameCasing = {}));
28
+ // only export types of depend packages
29
+ __exportStar(require("@volar/language-service/out/types"), exports);
30
+ __exportStar(require("@vue/language-core/out/types"), exports);
31
+ //# sourceMappingURL=types.js.map
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@vue/language-service",
3
+ "version": "1.7.0",
4
+ "main": "out/index.js",
5
+ "license": "MIT",
6
+ "files": [
7
+ "data",
8
+ "out/**/*.js",
9
+ "out/**/*.d.ts"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/vuejs/language-tools.git",
14
+ "directory": "packages/vue-language-service"
15
+ },
16
+ "scripts": {
17
+ "update-html-data": "node ./scripts/update-html-data.js"
18
+ },
19
+ "dependencies": {
20
+ "@volar/language-core": "1.5.4",
21
+ "@volar/language-service": "1.5.4",
22
+ "@volar/source-map": "1.5.4",
23
+ "@vue/compiler-dom": "^3.3.0-beta.3",
24
+ "@vue/language-core": "1.7.0",
25
+ "@vue/reactivity": "^3.3.0-beta.3",
26
+ "@vue/shared": "^3.3.0-beta.3",
27
+ "volar-service-css": "0.0.2",
28
+ "volar-service-emmet": "0.0.2",
29
+ "volar-service-html": "0.0.2",
30
+ "volar-service-json": "0.0.2",
31
+ "volar-service-pug": "0.0.2",
32
+ "volar-service-pug-beautify": "0.0.2",
33
+ "volar-service-typescript": "0.0.2",
34
+ "volar-service-typescript-twoslash-queries": "0.0.2",
35
+ "vscode-html-languageservice": "^5.0.4",
36
+ "vscode-json-languageservice": "^5.2.0",
37
+ "vscode-languageserver-protocol": "^3.17.3",
38
+ "vscode-languageserver-textdocument": "^1.0.8",
39
+ "vscode-uri": "^3.0.7"
40
+ },
41
+ "devDependencies": {
42
+ "@volar/kit": "1.5.4"
43
+ }
44
+ }