@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
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDragImportEdits = void 0;
4
- const shared_1 = require("@vue/shared");
5
- const path = require("path-browserify");
6
- const vue_extract_file_1 = require("../plugins/vue-extract-file");
7
- const types_1 = require("../types");
8
- function getDragImportEdits(ts, ctx, uri, importUri, casing) {
9
- let baseName = importUri.substring(importUri.lastIndexOf('/') + 1);
10
- baseName = baseName.substring(0, baseName.lastIndexOf('.'));
11
- const newName = (0, shared_1.capitalize)((0, shared_1.camelize)(baseName));
12
- const document = ctx.getTextDocument(uri);
13
- const [vueFile] = ctx.documents.getVirtualFileByUri(document.uri);
14
- const { sfc } = vueFile;
15
- const script = sfc.scriptSetup ?? sfc.script;
16
- if (!sfc.template || !script)
17
- return;
18
- const lastImportNode = (0, vue_extract_file_1.getLastImportNode)(ts, script.ast);
19
- const edits = [
20
- {
21
- range: lastImportNode ? {
22
- start: document.positionAt(script.startTagEnd + lastImportNode.end),
23
- end: document.positionAt(script.startTagEnd + lastImportNode.end),
24
- } : {
25
- start: document.positionAt(script.startTagEnd),
26
- end: document.positionAt(script.startTagEnd),
27
- },
28
- newText: `\nimport ${newName} from './${path.relative(path.dirname(uri), importUri) || importUri.substring(importUri.lastIndexOf('/') + 1)}'`,
29
- },
30
- ];
31
- if (sfc.script) {
32
- const edit = (0, vue_extract_file_1.createAddComponentToOptionEdit)(ts, sfc.script.ast, newName);
33
- if (edit) {
34
- edits.push({
35
- range: {
36
- start: document.positionAt(sfc.script.startTagEnd + edit.range.start),
37
- end: document.positionAt(sfc.script.startTagEnd + edit.range.end),
38
- },
39
- newText: edit.newText,
40
- });
41
- }
42
- }
43
- return {
44
- insertText: `<${casing === types_1.TagNameCasing.Kebab ? (0, shared_1.hyphenate)(newName) : newName}$0 />`,
45
- insertTextFormat: 2,
46
- additionalEdits: edits,
47
- };
48
- }
49
- exports.getDragImportEdits = getDragImportEdits;
50
- //# sourceMappingURL=dragImport.js.map
@@ -1,16 +0,0 @@
1
- import { ServiceContext } from '@volar/language-service';
2
- import { VueCompilerOptions } from '@vue/language-core';
3
- import type { Provide } from 'volar-service-typescript';
4
- import type * as vscode from 'vscode-languageserver-protocol';
5
- import { AttrNameCasing, TagNameCasing } from '../types';
6
- export declare function convertTagName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext<Provide>, uri: string, casing: TagNameCasing, vueCompilerOptions: VueCompilerOptions): Promise<vscode.TextEdit[] | undefined>;
7
- export declare function convertAttrName(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, casing: AttrNameCasing, vueCompilerOptions: VueCompilerOptions): Promise<vscode.TextEdit[] | undefined>;
8
- export declare function getNameCasing(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, vueCompilerOptions: VueCompilerOptions): Promise<{
9
- tag: TagNameCasing;
10
- attr: AttrNameCasing;
11
- }>;
12
- export declare function detect(ts: typeof import('typescript/lib/tsserverlibrary'), context: ServiceContext, uri: string, vueCompilerOptions: VueCompilerOptions): {
13
- tag: TagNameCasing[];
14
- attr: AttrNameCasing[];
15
- };
16
- //# sourceMappingURL=nameCasing.d.ts.map
package/out/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from '@volar/language-service';
2
- export * from '@vue/language-core';
3
- export * from './ideFeatures/nameCasing';
4
- export * from './ideFeatures/dragImport';
5
- export * from './languageService';
6
- export { TagNameCasing, AttrNameCasing } from './types';
7
- export { Provide } from './plugins/vue';
8
- //# sourceMappingURL=index.d.ts.map
package/out/index.js DELETED
@@ -1,26 +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
- __exportStar(require("@volar/language-service"), exports);
19
- __exportStar(require("@vue/language-core"), exports);
20
- __exportStar(require("./ideFeatures/nameCasing"), exports);
21
- __exportStar(require("./ideFeatures/dragImport"), exports);
22
- __exportStar(require("./languageService"), exports);
23
- var types_1 = require("./types");
24
- Object.defineProperty(exports, "TagNameCasing", { enumerable: true, get: function () { return types_1.TagNameCasing; } });
25
- Object.defineProperty(exports, "AttrNameCasing", { enumerable: true, get: function () { return types_1.AttrNameCasing; } });
26
- //# sourceMappingURL=index.js.map
@@ -1,9 +0,0 @@
1
- import { Config } from '@volar/language-service';
2
- import type * as ts from 'typescript/lib/tsserverlibrary';
3
- import { VueCompilerOptions } from './types';
4
- import * as JsonService from 'volar-service-json';
5
- export interface Settings {
6
- json?: Parameters<typeof JsonService['create']>[0];
7
- }
8
- export declare function resolveConfig(ts: typeof import('typescript/lib/tsserverlibrary'), config: Config, compilerOptions?: ts.CompilerOptions, vueCompilerOptions?: Partial<VueCompilerOptions>, codegenStack?: boolean): Config;
9
- //# sourceMappingURL=languageService.d.ts.map
@@ -1,239 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveConfig = void 0;
4
- const language_core_1 = require("@vue/language-core");
5
- const shared_1 = require("@vue/shared");
6
- const nameCasing_1 = require("./ideFeatures/nameCasing");
7
- const types_1 = require("./types");
8
- // volar services
9
- const CssService = require("volar-service-css");
10
- const EmmetService = require("volar-service-emmet");
11
- const HtmlService = require("volar-service-html");
12
- const JsonService = require("volar-service-json");
13
- const PugService = require("volar-service-pug");
14
- const PugFormatService = require("volar-service-pug-beautify");
15
- const TsService = require("volar-service-typescript");
16
- const TsTqService = require("volar-service-typescript-twoslash-queries");
17
- // our services
18
- const VueService = require("./plugins/vue");
19
- const AutoDotValueService = require("./plugins/vue-autoinsert-dotvalue");
20
- const AutoWrapParenthesesService = require("./plugins/vue-autoinsert-parentheses");
21
- const AutoAddSpaceService = require("./plugins/vue-autoinsert-space");
22
- const ReferencesCodeLensService = require("./plugins/vue-codelens-references");
23
- const DirectiveCommentsService = require("./plugins/vue-directive-comments");
24
- const ExtractComponentService = require("./plugins/vue-extract-file");
25
- const VueTemplateLanguageService = require("./plugins/vue-template");
26
- const ToggleVBindService = require("./plugins/vue-toggle-v-bind-codeaction");
27
- const VueTqService = require("./plugins/vue-twoslash-queries");
28
- const VisualizeHiddenCallbackParamService = require("./plugins/vue-visualize-hidden-callback-param");
29
- function resolveConfig(ts, config, compilerOptions = {}, vueCompilerOptions = {}, codegenStack = false) {
30
- const resolvedVueCompilerOptions = (0, language_core_1.resolveVueCompilerOptions)(vueCompilerOptions);
31
- const vueLanguageModules = (0, language_core_1.createLanguages)(ts, compilerOptions, resolvedVueCompilerOptions, codegenStack);
32
- config.languages = Object.assign({}, vueLanguageModules, config.languages);
33
- config.services = resolvePlugins(config.services, resolvedVueCompilerOptions);
34
- return config;
35
- }
36
- exports.resolveConfig = resolveConfig;
37
- function resolvePlugins(services, vueCompilerOptions) {
38
- const originalTsPlugin = services?.typescript ?? TsService.create();
39
- services ??= {};
40
- services.typescript = (ctx, modules) => {
41
- const base = typeof originalTsPlugin === 'function' ? originalTsPlugin(ctx, modules) : originalTsPlugin;
42
- if (!ctx || !modules?.typescript)
43
- return base;
44
- const ts = modules.typescript;
45
- return {
46
- ...base,
47
- async provideCompletionItems(document, position, context, item) {
48
- const result = await base.provideCompletionItems?.(document, position, context, item);
49
- if (result) {
50
- // filter __VLS_
51
- result.items = result.items.filter(item => item.label.indexOf('__VLS_') === -1
52
- && (!item.labelDetails?.description || item.labelDetails.description.indexOf('__VLS_') === -1));
53
- // handle component auto-import patch
54
- let casing;
55
- for (const [_, map] of ctx.documents.getMapsByVirtualFileUri(document.uri)) {
56
- const virtualFile = ctx.documents.getSourceByUri(map.sourceFileDocument.uri)?.root;
57
- if (virtualFile instanceof language_core_1.VueFile) {
58
- const isAutoImport = !!map.toSourcePosition(position, data => typeof data.completion === 'object' && !!data.completion.autoImportOnly);
59
- if (isAutoImport) {
60
- const source = ctx.documents.getVirtualFileByUri(document.uri)[1];
61
- for (const item of result.items) {
62
- item.data.__isComponentAutoImport = true;
63
- }
64
- // fix #2458
65
- if (source) {
66
- casing ??= await (0, nameCasing_1.getNameCasing)(ts, ctx, ctx.env.fileNameToUri(source.fileName), vueCompilerOptions);
67
- if (casing.tag === types_1.TagNameCasing.Kebab) {
68
- for (const item of result.items) {
69
- item.filterText = (0, language_core_1.hyphenateTag)(item.filterText ?? item.label);
70
- }
71
- }
72
- }
73
- }
74
- }
75
- }
76
- }
77
- return result;
78
- },
79
- async resolveCompletionItem(item, token) {
80
- item = await base.resolveCompletionItem?.(item, token) ?? item;
81
- const itemData = item.data;
82
- let newName;
83
- if (itemData?.uri && item.additionalTextEdits) {
84
- patchAdditionalTextEdits(itemData.uri, item.additionalTextEdits);
85
- }
86
- for (const ext of vueCompilerOptions.extensions) {
87
- const suffix = (0, shared_1.capitalize)(ext.substring('.'.length)); // .vue -> Vue
88
- if (itemData?.uri
89
- && item.textEdit?.newText.endsWith(suffix)
90
- && item.additionalTextEdits?.length === 1 && item.additionalTextEdits[0].newText.indexOf('import ' + item.textEdit.newText + ' from ') >= 0
91
- && (await ctx.env.getConfiguration?.('vue.complete.normalizeComponentImportName') ?? true)) {
92
- newName = item.textEdit.newText.slice(0, -suffix.length);
93
- newName = newName[0].toUpperCase() + newName.substring(1);
94
- if (newName === 'Index') {
95
- const tsItem = item.data.originalItem;
96
- if (tsItem.source) {
97
- const dirs = tsItem.source.split('/');
98
- if (dirs.length >= 3) {
99
- newName = dirs[dirs.length - 2];
100
- newName = newName[0].toUpperCase() + newName.substring(1);
101
- }
102
- }
103
- }
104
- item.additionalTextEdits[0].newText = item.additionalTextEdits[0].newText.replace('import ' + item.textEdit.newText + ' from ', 'import ' + newName + ' from ');
105
- item.textEdit.newText = newName;
106
- const source = ctx.documents.getVirtualFileByUri(itemData.uri)[1];
107
- if (source) {
108
- const casing = await (0, nameCasing_1.getNameCasing)(ts, ctx, ctx.env.fileNameToUri(source.fileName), vueCompilerOptions);
109
- if (casing.tag === types_1.TagNameCasing.Kebab) {
110
- item.textEdit.newText = (0, language_core_1.hyphenateTag)(item.textEdit.newText);
111
- }
112
- }
113
- }
114
- else if (item.textEdit?.newText && new RegExp(`import \\w*${suffix}\\$1 from [\\S\\s]*`).test(item.textEdit.newText)) {
115
- // https://github.com/vuejs/language-tools/issues/2286
116
- item.textEdit.newText = item.textEdit.newText.replace(`${suffix}$1`, '$1');
117
- }
118
- }
119
- const data = item.data;
120
- if (item.data?.__isComponentAutoImport && data && item.additionalTextEdits?.length && item.textEdit && itemData?.uri) {
121
- const fileName = ctx.env.uriToFileName(itemData.uri);
122
- const langaugeService = ctx.inject('typescript/languageService');
123
- const [virtualFile] = ctx.virtualFiles.getVirtualFile(fileName);
124
- const ast = langaugeService.getProgram()?.getSourceFile(fileName);
125
- const exportDefault = ast ? language_core_1.scriptRanges.parseScriptRanges(ts, ast, false, true).exportDefault : undefined;
126
- if (virtualFile && ast && exportDefault) {
127
- const componentName = newName ?? item.textEdit.newText;
128
- const optionEdit = ExtractComponentService.createAddComponentToOptionEdit(ts, ast, componentName);
129
- if (optionEdit) {
130
- const textDoc = ctx.documents.getDocumentByFileName(virtualFile.snapshot, virtualFile.fileName);
131
- item.additionalTextEdits.push({
132
- range: {
133
- start: textDoc.positionAt(optionEdit.range.start),
134
- end: textDoc.positionAt(optionEdit.range.end),
135
- },
136
- newText: optionEdit.newText,
137
- });
138
- }
139
- }
140
- }
141
- return item;
142
- },
143
- async provideCodeActions(document, range, context, token) {
144
- const result = await base.provideCodeActions?.(document, range, context, token);
145
- return result?.filter(codeAction => codeAction.title.indexOf('__VLS_') === -1);
146
- },
147
- async resolveCodeAction(item, token) {
148
- const result = await base.resolveCodeAction?.(item, token) ?? item;
149
- if (result?.edit?.changes) {
150
- for (const uri in result.edit.changes) {
151
- const edits = result.edit.changes[uri];
152
- if (edits) {
153
- patchAdditionalTextEdits(uri, edits);
154
- }
155
- }
156
- }
157
- if (result?.edit?.documentChanges) {
158
- for (const documentChange of result.edit.documentChanges) {
159
- if ('textDocument' in documentChange) {
160
- patchAdditionalTextEdits(documentChange.textDocument.uri, documentChange.edits);
161
- }
162
- }
163
- }
164
- return result;
165
- },
166
- async provideSemanticDiagnostics(document, token) {
167
- const result = await base.provideSemanticDiagnostics?.(document, token);
168
- return result?.map(diagnostic => {
169
- if (diagnostic.source === 'ts'
170
- && diagnostic.code === 2578 /* Unused '@ts-expect-error' directive. */
171
- && document.getText(diagnostic.range) === '// @ts-expect-error __VLS_TS_EXPECT_ERROR') {
172
- diagnostic.source = 'vue';
173
- diagnostic.code = 'ts-2578';
174
- diagnostic.message = diagnostic.message.replace(/@ts-expect-error/g, '@vue-expect-error');
175
- }
176
- return diagnostic;
177
- });
178
- },
179
- };
180
- };
181
- services.html ??= VueTemplateLanguageService.create({
182
- baseService: HtmlService.create(),
183
- getScanner: (htmlService, document) => {
184
- return htmlService.provide['html/languageService']().createScanner(document.getText());
185
- },
186
- updateCustomData(htmlService, extraData) {
187
- htmlService.provide['html/updateCustomData'](extraData);
188
- },
189
- isSupportedDocument: (document) => document.languageId === 'html',
190
- vueCompilerOptions,
191
- });
192
- services.pug ??= VueTemplateLanguageService.create({
193
- baseService: PugService.create(),
194
- getScanner: (pugService, document) => {
195
- const pugDocument = pugService.provide['pug/pugDocument'](document);
196
- if (pugDocument) {
197
- return pugService.provide['pug/languageService']().createScanner(pugDocument);
198
- }
199
- },
200
- updateCustomData(pugService, extraData) {
201
- pugService.provide['pug/updateCustomData'](extraData);
202
- },
203
- isSupportedDocument: (document) => document.languageId === 'jade',
204
- vueCompilerOptions,
205
- });
206
- services.vue ??= VueService.create();
207
- services.css ??= CssService.create();
208
- services['pug-beautify'] ??= PugFormatService.create();
209
- services.json ??= JsonService.create();
210
- services['typescript/twoslash-queries'] ??= TsTqService.create();
211
- services['vue/referencesCodeLens'] ??= ReferencesCodeLensService.create();
212
- services['vue/autoInsertDotValue'] ??= AutoDotValueService.create();
213
- services['vue/twoslash-queries'] ??= VueTqService.create();
214
- services['vue/autoInsertParentheses'] ??= AutoWrapParenthesesService.create();
215
- services['vue/autoInsertSpaces'] ??= AutoAddSpaceService.create();
216
- services['vue/visualizeHiddenCallbackParam'] ??= VisualizeHiddenCallbackParamService.create();
217
- services['vue/directiveComments'] ??= DirectiveCommentsService.create();
218
- services['vue/extractComponent'] ??= ExtractComponentService.create();
219
- services['vue/toggleVBind'] ??= ToggleVBindService.create();
220
- services.emmet ??= EmmetService.create();
221
- return services;
222
- }
223
- // fix https://github.com/vuejs/language-tools/issues/916
224
- function patchAdditionalTextEdits(uri, edits) {
225
- if (uri.endsWith('.vue.js')
226
- || uri.endsWith('.vue.ts')
227
- || uri.endsWith('.vue.jsx')
228
- || uri.endsWith('.vue.tsx')) {
229
- for (const edit of edits) {
230
- if (edit.range.start.line === 0
231
- && edit.range.start.character === 0
232
- && edit.range.end.line === 0
233
- && edit.range.end.character === 0) {
234
- edit.newText = '\n' + edit.newText;
235
- }
236
- }
237
- }
238
- }
239
- //# sourceMappingURL=languageService.js.map
@@ -1,7 +0,0 @@
1
- import { AutoInsertionContext, Service } from '@volar/language-service';
2
- import type * as ts from 'typescript/lib/tsserverlibrary';
3
- import type { TextDocument } from 'vscode-languageserver-textdocument';
4
- export declare const create: () => Service;
5
- export declare function isCharacterTyping(document: TextDocument, options: AutoInsertionContext): boolean;
6
- export declare function isBlacklistNode(ts: typeof import('typescript/lib/tsserverlibrary'), node: ts.Node, pos: number, allowAccessDotValue: boolean): boolean;
7
- //# sourceMappingURL=vue-autoinsert-dotvalue.d.ts.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-autoinsert-parentheses.d.ts.map
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const vue_autoinsert_dotvalue_1 = require("./vue-autoinsert-dotvalue");
5
- const plugin = (context, modules) => {
6
- if (!context) {
7
- return {};
8
- }
9
- if (!modules?.typescript) {
10
- return {};
11
- }
12
- const ts = modules.typescript;
13
- return {
14
- async provideAutoInsertionEdit(document, position, options_2) {
15
- const enabled = await context.env.getConfiguration?.('vue.autoInsert.parentheses') ?? false;
16
- if (!enabled)
17
- return;
18
- if (!(0, vue_autoinsert_dotvalue_1.isCharacterTyping)(document, options_2))
19
- return;
20
- const [virtualFile] = context.documents.getVirtualFileByUri(document.uri);
21
- if (!virtualFile?.fileName.endsWith('.template_format.ts'))
22
- return;
23
- const offset = document.offsetAt(position);
24
- for (const mappedRange of virtualFile.mappings) {
25
- if (mappedRange.generatedRange[1] === offset) {
26
- const text = document.getText().substring(mappedRange.generatedRange[0], mappedRange.generatedRange[1]);
27
- const ast = ts.createSourceFile(virtualFile.fileName, text, ts.ScriptTarget.Latest);
28
- if (ast.statements.length === 1) {
29
- const statement = ast.statements[0];
30
- if (ts.isExpressionStatement(statement)
31
- && ((ts.isAsExpression(statement.expression)
32
- && ts.isTypeReferenceNode(statement.expression.type)
33
- && ts.isIdentifier(statement.expression.type.typeName)
34
- && statement.expression.type.typeName.text)
35
- || (ts.isBinaryExpression(statement.expression)
36
- && statement.expression.right.getText(ast)
37
- && statement.expression.operatorToken.kind === ts.SyntaxKind.InstanceOfKeyword)
38
- || (ts.isTypeOfExpression(statement.expression)
39
- && statement.expression.expression.getText(ast)))) {
40
- // https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar
41
- const escapedText = text
42
- .replaceAll('\\', '\\\\')
43
- .replaceAll('$', '\\$')
44
- .replaceAll('}', '\\}');
45
- return {
46
- range: {
47
- start: document.positionAt(mappedRange.generatedRange[0]),
48
- end: document.positionAt(mappedRange.generatedRange[1]),
49
- },
50
- newText: '(' + escapedText + '$0' + ')',
51
- };
52
- }
53
- }
54
- }
55
- }
56
- },
57
- };
58
- };
59
- const create = () => plugin;
60
- exports.create = create;
61
- //# sourceMappingURL=vue-autoinsert-parentheses.js.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-autoinsert-space.d.ts.map
@@ -1,32 +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 provideAutoInsertionEdit(document, _, { lastChange }) {
9
- if (document.languageId === 'html' || document.languageId === 'jade') {
10
- const enabled = await context.env.getConfiguration?.('vue.autoInsert.bracketSpacing') ?? true;
11
- if (!enabled)
12
- return;
13
- if (lastChange.text === '{}'
14
- && document.getText({
15
- start: { line: lastChange.range.start.line, character: lastChange.range.start.character - 1 },
16
- end: { line: lastChange.range.start.line, character: lastChange.range.start.character + 3 }
17
- }) === '{{}}') {
18
- return {
19
- newText: ` $0 `,
20
- range: {
21
- start: { line: lastChange.range.start.line, character: lastChange.range.start.character + 1 },
22
- end: { line: lastChange.range.start.line, character: lastChange.range.start.character + 1 }
23
- },
24
- };
25
- }
26
- }
27
- },
28
- };
29
- };
30
- const create = () => plugin;
31
- exports.create = create;
32
- //# sourceMappingURL=vue-autoinsert-space.js.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-codelens-references.d.ts.map
@@ -1,54 +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 (context) => {
7
- if (!context)
8
- return {};
9
- return {
10
- provideReferencesCodeLensRanges(document) {
11
- return worker(document.uri, async () => {
12
- const result = [];
13
- for (const [_, map] of context.documents.getMapsBySourceFileUri(document.uri)?.maps ?? []) {
14
- for (const mapping of map.map.mappings) {
15
- if (!mapping.data.referencesCodeLens)
16
- continue;
17
- result.push({
18
- start: document.positionAt(mapping.sourceRange[0]),
19
- end: document.positionAt(mapping.sourceRange[1]),
20
- });
21
- }
22
- }
23
- return result;
24
- });
25
- },
26
- async resolveReferencesCodeLensLocations(document, range, references) {
27
- await worker(document.uri, async (vueFile) => {
28
- const document = context.documents.getDocumentByFileName(vueFile.snapshot, vueFile.fileName);
29
- const offset = document.offsetAt(range.start);
30
- const blocks = [
31
- vueFile.sfc.script,
32
- vueFile.sfc.scriptSetup,
33
- vueFile.sfc.template,
34
- ...vueFile.sfc.styles,
35
- ...vueFile.sfc.customBlocks,
36
- ];
37
- const sourceBlock = blocks.find(block => block && offset >= block.startTagEnd && offset <= block.endTagStart);
38
- references = references.filter(reference => reference.uri !== document.uri // different file
39
- || sourceBlock !== blocks.find(block => block && document.offsetAt(reference.range.start) >= block.startTagEnd && document.offsetAt(reference.range.end) <= block.endTagStart) // different block
40
- );
41
- });
42
- return references;
43
- },
44
- };
45
- function worker(uri, callback) {
46
- const [virtualFile] = context.documents.getVirtualFileByUri(uri);
47
- if (!(virtualFile instanceof language_core_1.VueFile))
48
- return;
49
- return callback(virtualFile);
50
- }
51
- };
52
- };
53
- exports.create = create;
54
- //# sourceMappingURL=vue-codelens-references.js.map
@@ -1,3 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- export declare const create: () => Service;
3
- //# sourceMappingURL=vue-directive-comments.d.ts.map
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const cmds = [
5
- 'vue-ignore',
6
- 'vue-skip',
7
- 'vue-expect-error',
8
- ];
9
- const directiveCommentReg = /<!--\s*@/;
10
- const plugin = () => {
11
- return {
12
- triggerCharacters: ['@'],
13
- provideCompletionItems(document, position) {
14
- if (document.languageId !== 'html')
15
- return;
16
- const line = document.getText({ start: { line: position.line, character: 0 }, end: position });
17
- const cmdStart = line.match(directiveCommentReg);
18
- if (!cmdStart)
19
- return;
20
- const startIndex = cmdStart.index + cmdStart[0].length;
21
- const remainText = line.substring(startIndex);
22
- const result = [];
23
- for (const cmd of cmds) {
24
- let match = true;
25
- for (let i = 0; i < remainText.length; i++) {
26
- if (remainText[i] !== cmd[i]) {
27
- console.log(JSON.stringify(remainText[i]), JSON.stringify(cmd[i]));
28
- match = false;
29
- break;
30
- }
31
- }
32
- if (match) {
33
- result.push({
34
- label: '@' + cmd,
35
- textEdit: {
36
- range: {
37
- start: {
38
- line: position.line,
39
- character: startIndex - 1,
40
- },
41
- end: position,
42
- },
43
- newText: '@' + cmd,
44
- },
45
- });
46
- }
47
- }
48
- return {
49
- isIncomplete: false,
50
- items: result,
51
- };
52
- },
53
- };
54
- };
55
- const create = () => plugin;
56
- exports.create = create;
57
- //# sourceMappingURL=vue-directive-comments.js.map
@@ -1,9 +0,0 @@
1
- import { Service } from '@volar/language-service';
2
- import type * as ts from 'typescript/lib/tsserverlibrary';
3
- export declare const create: () => Service;
4
- export declare function getLastImportNode(ts: typeof import('typescript/lib/tsserverlibrary'), sourceFile: ts.SourceFile): ts.Node | undefined;
5
- export declare function createAddComponentToOptionEdit(ts: typeof import('typescript/lib/tsserverlibrary'), ast: ts.SourceFile, componentName: string): {
6
- range: import("@vue/language-core").TextRange;
7
- newText: string;
8
- } | undefined;
9
- //# sourceMappingURL=vue-extract-file.d.ts.map