@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,15 @@
1
+ import * as embedded from '@volar/language-core';
2
+ import type * as ts from 'typescript/lib/tsserverlibrary';
3
+ export declare function checkPropsOfTag(ts: typeof import('typescript/lib/tsserverlibrary'), tsLs: ts.LanguageService, sourceFile: embedded.VirtualFile, tag: string, nativeTags: Set<string>, requiredOnly?: boolean): string[];
4
+ export declare function checkEventsOfTag(ts: typeof import('typescript/lib/tsserverlibrary'), tsLs: ts.LanguageService, sourceFile: embedded.VirtualFile, tag: string, nativeTags: Set<string>): string[];
5
+ export declare function checkComponentNames(ts: typeof import('typescript/lib/tsserverlibrary'), tsLs: ts.LanguageService, sourceFile: embedded.VirtualFile, nativeTags: Set<string>): string[];
6
+ export declare function checkNativeTags(ts: typeof import('typescript/lib/tsserverlibrary'), tsLs: ts.LanguageService, fileName: string): Set<string>;
7
+ export declare function getElementAttrs(ts: typeof import('typescript/lib/tsserverlibrary'), tsLs: ts.LanguageService, fileName: string, tagName: string): string[];
8
+ type Tags = Map<string, {
9
+ offsets: number[];
10
+ attrs: Map<string, {
11
+ offsets: number[];
12
+ }>;
13
+ }>;
14
+ export declare function getTemplateTagsAndAttrs(sourceFile: embedded.VirtualFile): Tags;
15
+ export {};
package/out/helpers.js ADDED
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTemplateTagsAndAttrs = exports.getElementAttrs = exports.checkNativeTags = exports.checkComponentNames = exports.checkEventsOfTag = exports.checkPropsOfTag = void 0;
4
+ const vue = require("@vue/language-core");
5
+ const embedded = require("@volar/language-core");
6
+ const reactivity_1 = require("@vue/reactivity");
7
+ const language_core_1 = require("@vue/language-core");
8
+ const shared_1 = require("@vue/shared");
9
+ function checkPropsOfTag(ts, tsLs, sourceFile, tag, nativeTags, requiredOnly = false) {
10
+ const checker = tsLs.getProgram().getTypeChecker();
11
+ const components = getComponentsType(ts, tsLs, sourceFile);
12
+ if (!components)
13
+ return [];
14
+ const name = tag.split('.');
15
+ let componentSymbol = components.componentsType.getProperty(name[0]);
16
+ if (!componentSymbol && !nativeTags.has(name[0])) {
17
+ componentSymbol = components.componentsType.getProperty((0, shared_1.camelize)(name[0]))
18
+ ?? components.componentsType.getProperty((0, shared_1.capitalize)((0, shared_1.camelize)(name[0])));
19
+ }
20
+ if (!componentSymbol)
21
+ return [];
22
+ let componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.componentsNode);
23
+ for (let i = 1; i < name.length; i++) {
24
+ componentSymbol = componentType.getProperty(name[i]);
25
+ if (componentSymbol) {
26
+ componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.componentsNode);
27
+ }
28
+ else {
29
+ return [];
30
+ }
31
+ }
32
+ const result = new Set();
33
+ for (const sig of componentType.getCallSignatures()) {
34
+ const propParam = sig.parameters[0];
35
+ if (propParam) {
36
+ const propsType = checker.getTypeOfSymbolAtLocation(propParam, components.componentsNode);
37
+ const props = propsType.getProperties();
38
+ for (const prop of props) {
39
+ if (!requiredOnly || !(prop.flags & ts.SymbolFlags.Optional)) {
40
+ result.add(prop.name);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ for (const sig of componentType.getConstructSignatures()) {
46
+ const instanceType = sig.getReturnType();
47
+ const propsSymbol = instanceType.getProperty('$props');
48
+ if (propsSymbol) {
49
+ const propsType = checker.getTypeOfSymbolAtLocation(propsSymbol, components.componentsNode);
50
+ const props = propsType.getProperties();
51
+ for (const prop of props) {
52
+ if (prop.flags & ts.SymbolFlags.Method) { // #2443
53
+ continue;
54
+ }
55
+ if (!requiredOnly || !(prop.flags & ts.SymbolFlags.Optional)) {
56
+ result.add(prop.name);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return [...result];
62
+ }
63
+ exports.checkPropsOfTag = checkPropsOfTag;
64
+ function checkEventsOfTag(ts, tsLs, sourceFile, tag, nativeTags) {
65
+ const checker = tsLs.getProgram().getTypeChecker();
66
+ const components = getComponentsType(ts, tsLs, sourceFile);
67
+ if (!components)
68
+ return [];
69
+ const name = tag.split('.');
70
+ let componentSymbol = components.componentsType.getProperty(name[0]);
71
+ if (!componentSymbol && !nativeTags.has(name[0])) {
72
+ componentSymbol = components.componentsType.getProperty((0, shared_1.camelize)(name[0]))
73
+ ?? components.componentsType.getProperty((0, shared_1.capitalize)((0, shared_1.camelize)(name[0])));
74
+ }
75
+ if (!componentSymbol)
76
+ return [];
77
+ let componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.componentsNode);
78
+ for (let i = 1; i < name.length; i++) {
79
+ componentSymbol = componentType.getProperty(name[i]);
80
+ if (componentSymbol) {
81
+ componentType = checker.getTypeOfSymbolAtLocation(componentSymbol, components.componentsNode);
82
+ }
83
+ else {
84
+ return [];
85
+ }
86
+ }
87
+ const result = new Set();
88
+ // for (const sig of componentType.getCallSignatures()) {
89
+ // const emitParam = sig.parameters[1];
90
+ // if (emitParam) {
91
+ // // TODO
92
+ // }
93
+ // }
94
+ for (const sig of componentType.getConstructSignatures()) {
95
+ const instanceType = sig.getReturnType();
96
+ const emitSymbol = instanceType.getProperty('$emit');
97
+ if (emitSymbol) {
98
+ const emitType = checker.getTypeOfSymbolAtLocation(emitSymbol, components.componentsNode);
99
+ for (const call of emitType.getCallSignatures()) {
100
+ const eventNameParamSymbol = call.parameters[0];
101
+ if (eventNameParamSymbol) {
102
+ const eventNameParamType = checker.getTypeOfSymbolAtLocation(eventNameParamSymbol, components.componentsNode);
103
+ if (eventNameParamType.isStringLiteral()) {
104
+ result.add(eventNameParamType.value);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ return [...result];
111
+ }
112
+ exports.checkEventsOfTag = checkEventsOfTag;
113
+ function checkComponentNames(ts, tsLs, sourceFile, nativeTags) {
114
+ return getComponentsType(ts, tsLs, sourceFile)
115
+ ?.componentsType
116
+ ?.getProperties()
117
+ .map(c => c.name)
118
+ .filter(entry => entry.indexOf('$') === -1 && !entry.startsWith('_'))
119
+ .filter(entry => !nativeTags.has(entry))
120
+ ?? [];
121
+ }
122
+ exports.checkComponentNames = checkComponentNames;
123
+ function checkNativeTags(ts, tsLs, fileName) {
124
+ const sharedTypesFileName = fileName.substring(0, fileName.lastIndexOf('/')) + '/' + language_core_1.sharedTypes.baseName;
125
+ const result = new Set();
126
+ let tsSourceFile;
127
+ if (tsSourceFile = tsLs.getProgram()?.getSourceFile(sharedTypesFileName)) {
128
+ const typeNode = tsSourceFile.statements.find((node) => ts.isTypeAliasDeclaration(node) && node.name.getText() === 'IntrinsicElements');
129
+ const checker = tsLs.getProgram()?.getTypeChecker();
130
+ if (checker && typeNode) {
131
+ const type = checker.getTypeFromTypeNode(typeNode.type);
132
+ const props = type.getProperties();
133
+ for (const prop of props) {
134
+ result.add(prop.name);
135
+ }
136
+ }
137
+ }
138
+ return result;
139
+ }
140
+ exports.checkNativeTags = checkNativeTags;
141
+ function getElementAttrs(ts, tsLs, fileName, tagName) {
142
+ const sharedTypesFileName = fileName.substring(0, fileName.lastIndexOf('/')) + '/' + language_core_1.sharedTypes.baseName;
143
+ let tsSourceFile;
144
+ if (tsSourceFile = tsLs.getProgram()?.getSourceFile(sharedTypesFileName)) {
145
+ const typeNode = tsSourceFile.statements.find((node) => ts.isTypeAliasDeclaration(node) && node.name.getText() === 'IntrinsicElements');
146
+ const checker = tsLs.getProgram()?.getTypeChecker();
147
+ if (checker && typeNode) {
148
+ const type = checker.getTypeFromTypeNode(typeNode.type);
149
+ const el = type.getProperty(tagName);
150
+ if (el) {
151
+ const attrs = checker.getTypeOfSymbolAtLocation(el, typeNode).getProperties();
152
+ return attrs.map(c => c.name);
153
+ }
154
+ }
155
+ }
156
+ return [];
157
+ }
158
+ exports.getElementAttrs = getElementAttrs;
159
+ function getComponentsType(ts, tsLs, sourceFile) {
160
+ if (!(sourceFile instanceof vue.VueFile)) {
161
+ return;
162
+ }
163
+ let file;
164
+ let tsSourceFile;
165
+ embedded.forEachEmbeddedFile(sourceFile, embedded => {
166
+ if (embedded.fileName === sourceFile.mainScriptName) {
167
+ file = embedded;
168
+ }
169
+ });
170
+ if (file && (tsSourceFile = tsLs.getProgram()?.getSourceFile(file.fileName))) {
171
+ const componentsNode = getComponentsNode(ts, tsSourceFile);
172
+ const checker = tsLs.getProgram()?.getTypeChecker();
173
+ if (checker && componentsNode) {
174
+ return {
175
+ componentsNode,
176
+ componentsType: checker.getTypeAtLocation(componentsNode),
177
+ };
178
+ }
179
+ }
180
+ function getComponentsNode(ts, sourceFile) {
181
+ let componentsNode;
182
+ walk(sourceFile);
183
+ return componentsNode;
184
+ function walk(node) {
185
+ if (componentsNode) {
186
+ return;
187
+ }
188
+ else if (ts.isVariableDeclaration(node) && node.name.getText() === '__VLS_components') {
189
+ componentsNode = node;
190
+ }
191
+ else {
192
+ node.forEachChild(walk);
193
+ }
194
+ }
195
+ }
196
+ }
197
+ const map = new WeakMap();
198
+ function getTemplateTagsAndAttrs(sourceFile) {
199
+ if (!map.has(sourceFile)) {
200
+ const getter = (0, reactivity_1.computed)(() => {
201
+ if (!(sourceFile instanceof vue.VueFile))
202
+ return;
203
+ const ast = sourceFile.compiledSFCTemplate?.ast;
204
+ const tags = new Map();
205
+ if (ast) {
206
+ vue.walkElementNodes(ast, node => {
207
+ if (!tags.has(node.tag)) {
208
+ tags.set(node.tag, { offsets: [], attrs: new Map() });
209
+ }
210
+ const tag = tags.get(node.tag);
211
+ const startTagHtmlOffset = node.loc.start.offset + node.loc.source.indexOf(node.tag);
212
+ const endTagHtmlOffset = node.loc.start.offset + node.loc.source.lastIndexOf(node.tag);
213
+ tag.offsets.push(startTagHtmlOffset);
214
+ if (!node.isSelfClosing) {
215
+ tag.offsets.push(endTagHtmlOffset);
216
+ }
217
+ for (const prop of node.props) {
218
+ let name;
219
+ let offset;
220
+ if (prop.type === 7 /* CompilerDOM.NodeTypes.DIRECTIVE */
221
+ && prop.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */
222
+ && prop.arg.isStatic) {
223
+ name = prop.arg.content;
224
+ offset = prop.arg.loc.start.offset;
225
+ }
226
+ else if (prop.type === 6 /* CompilerDOM.NodeTypes.ATTRIBUTE */) {
227
+ name = prop.name;
228
+ offset = prop.loc.start.offset;
229
+ }
230
+ if (name !== undefined && offset !== undefined) {
231
+ if (!tag.attrs.has(name)) {
232
+ tag.attrs.set(name, { offsets: [] });
233
+ }
234
+ tag.attrs.get(name).offsets.push(offset);
235
+ }
236
+ }
237
+ });
238
+ }
239
+ return tags;
240
+ });
241
+ map.set(sourceFile, getter);
242
+ }
243
+ return map.get(sourceFile).value ?? new Map();
244
+ }
245
+ exports.getTemplateTagsAndAttrs = getTemplateTagsAndAttrs;
246
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1,13 @@
1
+ import { ServiceContext } from '@volar/language-service';
2
+ import * as vscode from 'vscode-languageserver-protocol';
3
+ import { AttrNameCasing, TagNameCasing } from '../types';
4
+ export declare function convertTagName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, casing: TagNameCasing): Promise<vscode.TextEdit[] | undefined>;
5
+ export declare function convertAttrName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, casing: AttrNameCasing): Promise<vscode.TextEdit[] | undefined>;
6
+ export declare function getNameCasing(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string): Promise<{
7
+ tag: TagNameCasing;
8
+ attr: AttrNameCasing;
9
+ }>;
10
+ export declare function detect(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string): {
11
+ tag: TagNameCasing[];
12
+ attr: AttrNameCasing[];
13
+ };
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detect = exports.getNameCasing = exports.convertAttrName = exports.convertTagName = void 0;
4
+ const shared_1 = require("@vue/shared");
5
+ const helpers_1 = require("../helpers");
6
+ const vue = require("@vue/language-core");
7
+ const vscode = require("vscode-languageserver-protocol");
8
+ const types_1 = require("../types");
9
+ async function convertTagName(ts, context, uri, casing) {
10
+ if (!context.typescript)
11
+ return;
12
+ const rootFile = context.documents.getSourceByUri(uri)?.root;
13
+ if (!(rootFile instanceof vue.VueFile))
14
+ return;
15
+ const desc = rootFile.sfc;
16
+ if (!desc.template)
17
+ return;
18
+ const template = desc.template;
19
+ const document = context.documents.getDocumentByFileName(rootFile.snapshot, rootFile.fileName);
20
+ const edits = [];
21
+ const nativeTags = (0, helpers_1.checkNativeTags)(ts, context.typescript.languageService, rootFile.fileName);
22
+ const components = (0, helpers_1.checkComponentNames)(ts, context.typescript.languageService, rootFile, nativeTags);
23
+ const tags = (0, helpers_1.getTemplateTagsAndAttrs)(rootFile);
24
+ for (const [tagName, { offsets }] of tags) {
25
+ const componentName = components.find(component => component === tagName || (0, shared_1.hyphenate)(component) === tagName);
26
+ if (componentName) {
27
+ for (const offset of offsets) {
28
+ const start = document.positionAt(template.startTagEnd + offset);
29
+ const end = document.positionAt(template.startTagEnd + offset + tagName.length);
30
+ const range = vscode.Range.create(start, end);
31
+ if (casing === types_1.TagNameCasing.Kebab && tagName !== (0, shared_1.hyphenate)(componentName)) {
32
+ edits.push(vscode.TextEdit.replace(range, (0, shared_1.hyphenate)(componentName)));
33
+ }
34
+ if (casing === types_1.TagNameCasing.Pascal && tagName !== componentName) {
35
+ edits.push(vscode.TextEdit.replace(range, componentName));
36
+ }
37
+ }
38
+ }
39
+ }
40
+ return edits;
41
+ }
42
+ exports.convertTagName = convertTagName;
43
+ async function convertAttrName(ts, context, uri, casing) {
44
+ if (!context.typescript)
45
+ return;
46
+ const rootFile = context.documents.getSourceByUri(uri)?.root;
47
+ if (!(rootFile instanceof vue.VueFile))
48
+ return;
49
+ const desc = rootFile.sfc;
50
+ if (!desc.template)
51
+ return;
52
+ const template = desc.template;
53
+ const document = context.documents.getDocumentByFileName(rootFile.snapshot, rootFile.fileName);
54
+ const edits = [];
55
+ const nativeTags = (0, helpers_1.checkNativeTags)(ts, context.typescript.languageService, rootFile.fileName);
56
+ const components = (0, helpers_1.checkComponentNames)(ts, context.typescript.languageService, rootFile, nativeTags);
57
+ const tags = (0, helpers_1.getTemplateTagsAndAttrs)(rootFile);
58
+ for (const [tagName, { attrs }] of tags) {
59
+ const componentName = components.find(component => component === tagName || (0, shared_1.hyphenate)(component) === tagName);
60
+ if (componentName) {
61
+ const props = (0, helpers_1.checkPropsOfTag)(ts, context.typescript.languageService, rootFile, componentName, nativeTags);
62
+ for (const [attrName, { offsets }] of attrs) {
63
+ const propName = props.find(prop => prop === attrName || (0, shared_1.hyphenate)(prop) === attrName);
64
+ if (propName) {
65
+ for (const offset of offsets) {
66
+ const start = document.positionAt(template.startTagEnd + offset);
67
+ const end = document.positionAt(template.startTagEnd + offset + attrName.length);
68
+ const range = vscode.Range.create(start, end);
69
+ if (casing === types_1.AttrNameCasing.Kebab && attrName !== (0, shared_1.hyphenate)(propName)) {
70
+ edits.push(vscode.TextEdit.replace(range, (0, shared_1.hyphenate)(propName)));
71
+ }
72
+ if (casing === types_1.AttrNameCasing.Camel && attrName !== propName) {
73
+ edits.push(vscode.TextEdit.replace(range, propName));
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ return edits;
81
+ }
82
+ exports.convertAttrName = convertAttrName;
83
+ async function getNameCasing(ts, context, uri) {
84
+ const detected = detect(ts, context, uri);
85
+ const [attr, tag] = await Promise.all([
86
+ context.env.getConfiguration?.('vue.complete.casing.props', uri),
87
+ context.env.getConfiguration?.('vue.complete.casing.tags', uri),
88
+ ]);
89
+ const tagNameCasing = detected.tag.length === 1 && (tag === 'autoPascal' || tag === 'autoKebab') ? detected.tag[0] : (tag === 'autoKebab' || tag === 'kebab') ? types_1.TagNameCasing.Kebab : types_1.TagNameCasing.Pascal;
90
+ const attrNameCasing = detected.attr.length === 1 && (attr === 'autoCamel' || attr === 'autoKebab') ? detected.attr[0] : (attr === 'autoCamel' || attr === 'camel') ? types_1.AttrNameCasing.Camel : types_1.AttrNameCasing.Kebab;
91
+ return {
92
+ tag: tagNameCasing,
93
+ attr: attrNameCasing,
94
+ };
95
+ }
96
+ exports.getNameCasing = getNameCasing;
97
+ function detect(ts, context, uri) {
98
+ if (!context.typescript) {
99
+ return {
100
+ tag: [],
101
+ attr: [],
102
+ };
103
+ }
104
+ const rootFile = context.documents.getSourceByUri(uri)?.root;
105
+ if (!(rootFile instanceof vue.VueFile)) {
106
+ return {
107
+ tag: [],
108
+ attr: [],
109
+ };
110
+ }
111
+ return {
112
+ tag: getTagNameCase(rootFile),
113
+ attr: getAttrNameCase(rootFile),
114
+ };
115
+ function getAttrNameCase(file) {
116
+ const tags = (0, helpers_1.getTemplateTagsAndAttrs)(file);
117
+ const result = [];
118
+ for (const [_, { attrs }] of tags) {
119
+ for (const [tagName] of attrs) {
120
+ // attrName
121
+ if (tagName !== (0, shared_1.hyphenate)(tagName)) {
122
+ result.push(types_1.AttrNameCasing.Camel);
123
+ break;
124
+ }
125
+ }
126
+ for (const [tagName] of attrs) {
127
+ // attr-name
128
+ if (tagName.indexOf('-') >= 0) {
129
+ result.push(types_1.AttrNameCasing.Kebab);
130
+ break;
131
+ }
132
+ }
133
+ }
134
+ return result;
135
+ }
136
+ function getTagNameCase(file) {
137
+ if (!context.typescript) {
138
+ return [];
139
+ }
140
+ const nativeTags = (0, helpers_1.checkNativeTags)(ts, context.typescript.languageService, file.fileName);
141
+ const components = (0, helpers_1.checkComponentNames)(ts, context.typescript.languageService, file, nativeTags);
142
+ const tagNames = (0, helpers_1.getTemplateTagsAndAttrs)(file);
143
+ const result = [];
144
+ let anyComponentUsed = false;
145
+ for (const component of components) {
146
+ if (tagNames.has(component) || tagNames.has((0, shared_1.hyphenate)(component))) {
147
+ anyComponentUsed = true;
148
+ break;
149
+ }
150
+ }
151
+ if (!anyComponentUsed) {
152
+ return []; // not sure component style, because do not have any component using in <template> for check
153
+ }
154
+ for (const [tagName] of tagNames) {
155
+ // TagName
156
+ if (tagName !== (0, shared_1.hyphenate)(tagName)) {
157
+ result.push(types_1.TagNameCasing.Pascal);
158
+ break;
159
+ }
160
+ }
161
+ for (const component of components) {
162
+ // Tagname -> tagname
163
+ // TagName -> tag-name
164
+ if (component !== (0, shared_1.hyphenate)(component) && tagNames.has((0, shared_1.hyphenate)(component))) {
165
+ result.push(types_1.TagNameCasing.Kebab);
166
+ break;
167
+ }
168
+ }
169
+ return result;
170
+ }
171
+ }
172
+ exports.detect = detect;
173
+ //# sourceMappingURL=nameCasing.js.map
package/out/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from '@volar/language-service';
2
+ export * from './ideFeatures/nameCasing';
3
+ export * from './languageService';
4
+ export * from './types';
5
+ export { injectionKeys } from './plugins/vue';
package/out/index.js ADDED
@@ -0,0 +1,24 @@
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.injectionKeys = void 0;
18
+ __exportStar(require("@volar/language-service"), exports);
19
+ __exportStar(require("./ideFeatures/nameCasing"), exports);
20
+ __exportStar(require("./languageService"), exports);
21
+ __exportStar(require("./types"), exports);
22
+ var vue_1 = require("./plugins/vue");
23
+ Object.defineProperty(exports, "injectionKeys", { enumerable: true, get: function () { return vue_1.injectionKeys; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import createJsonPlugin from 'volar-service-json';
2
+ import * as vue from '@vue/language-core';
3
+ import type * as ts from 'typescript/lib/tsserverlibrary';
4
+ import { Config } from '@volar/language-service';
5
+ export interface Settings {
6
+ json?: Parameters<typeof createJsonPlugin>[0];
7
+ }
8
+ export declare function resolveConfig(config: Config, // volar.config.js
9
+ compilerOptions?: ts.CompilerOptions, vueCompilerOptions?: vue.VueCompilerOptions, settings?: Settings, ts?: typeof import('typescript/lib/tsserverlibrary')): Config;