@vue/language-service 1.8.21 → 1.8.24
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.
- package/data/template/ko.json +1 -1
- package/data/template/zh-cn.json +1 -1
- package/out/ideFeatures/dragImport.d.ts +9 -0
- package/out/ideFeatures/dragImport.js +50 -0
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/languageService.d.ts +1 -1
- package/out/languageService.js +2 -2
- package/out/plugins/vue-extract-file.d.ts +1 -0
- package/out/plugins/vue-extract-file.js +15 -14
- package/out/types.d.ts +1 -1
- package/out/types.js +1 -1
- package/package.json +18 -15
package/data/template/ko.json
CHANGED
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"name": "Teleport",
|
|
144
144
|
"description": {
|
|
145
145
|
"kind": "markdown",
|
|
146
|
-
"value": "\n슬롯 컨텐츠를 DOM 내 다른 위치에서 렌더링합니다.\n\n- **Props**\n\n ```ts\n interface TeleportProps {\n /**\n * 필수. 대상이 될 컨테이너를 지정.\n * 셀렉터 또는 실제 엘리먼트일 수 있음.\n */\n to: string | HTMLElement\n /**\n * `true`이면 컨텐츠가 대상이 될 컨테이너로\n * 이동하지 않고 원래 위치에 남아 있음.\n * 동적으로 변경할 수 있음.\n */\n disabled?: boolean\n }\n ```\n\n- **예제**\n\n 대상이 될 컨테이너 지정:\n\n ```html\n <
|
|
146
|
+
"value": "\n슬롯 컨텐츠를 DOM 내 다른 위치에서 렌더링합니다.\n\n- **Props**\n\n ```ts\n interface TeleportProps {\n /**\n * 필수. 대상이 될 컨테이너를 지정.\n * 셀렉터 또는 실제 엘리먼트일 수 있음.\n */\n to: string | HTMLElement\n /**\n * `true`이면 컨텐츠가 대상이 될 컨테이너로\n * 이동하지 않고 원래 위치에 남아 있음.\n * 동적으로 변경할 수 있음.\n */\n disabled?: boolean\n }\n ```\n\n- **예제**\n\n 대상이 될 컨테이너 지정:\n\n ```html\n <Teleport to=\"#some-id\" />\n <Teleport to=\".some-class\" />\n <Teleport to=\"[data-teleport]\" />\n ```\n\n 조건부 비활성화:\n\n ```html\n <Teleport to=\"#popup\" :disabled=\"displayVideoInline\">\n <video src=\"./my-movie.mp4\">\n </Teleport>\n ```\n\n- **참고** [가이드 - Teleport](https://ko.vuejs.org/guide/built-ins/teleport.html)\n"
|
|
147
147
|
},
|
|
148
148
|
"attributes": [],
|
|
149
149
|
"references": [
|
package/data/template/zh-cn.json
CHANGED
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"name": "Teleport",
|
|
144
144
|
"description": {
|
|
145
145
|
"kind": "markdown",
|
|
146
|
-
"value": "\n将其插槽内容渲染到 DOM 中的另一个位置。\n\n- **Props**\n\n ```ts\n interface TeleportProps {\n /**\n * 必填项。指定目标容器。\n * 可以是选择器或实际元素。\n */\n to: string | HTMLElement\n /**\n * 当值为 `true` 时,内容将保留在其原始位置\n * 而不是移动到目标容器中。\n * 可以动态更改。\n */\n disabled?: boolean\n }\n ```\n\n- **示例**\n\n 指定目标容器:\n\n ```html\n <
|
|
146
|
+
"value": "\n将其插槽内容渲染到 DOM 中的另一个位置。\n\n- **Props**\n\n ```ts\n interface TeleportProps {\n /**\n * 必填项。指定目标容器。\n * 可以是选择器或实际元素。\n */\n to: string | HTMLElement\n /**\n * 当值为 `true` 时,内容将保留在其原始位置\n * 而不是移动到目标容器中。\n * 可以动态更改。\n */\n disabled?: boolean\n }\n ```\n\n- **示例**\n\n 指定目标容器:\n\n ```html\n <Teleport to=\"#some-id\" />\n <Teleport to=\".some-class\" />\n <Teleport to=\"[data-teleport]\" />\n ```\n\n 有条件地禁用:\n\n ```html\n <Teleport to=\"#popup\" :disabled=\"displayVideoInline\">\n <video src=\"./my-movie.mp4\">\n </Teleport>\n ```\n\n- **参考**[指南 - Teleport](https://cn.vuejs.org/guide/built-ins/teleport.html)\n"
|
|
147
147
|
},
|
|
148
148
|
"attributes": [],
|
|
149
149
|
"references": [
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceContext } from '@volar/language-service';
|
|
2
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
+
import { TagNameCasing } from '../types';
|
|
4
|
+
export declare function getDragImportEdits(ts: typeof import('typescript/lib/tsserverlibrary'), ctx: ServiceContext, uri: string, importUri: string, casing: TagNameCasing): {
|
|
5
|
+
insertText: string;
|
|
6
|
+
insertTextFormat: vscode.InsertTextFormat;
|
|
7
|
+
additionalEdits: vscode.TextEdit[];
|
|
8
|
+
} | undefined;
|
|
9
|
+
//# sourceMappingURL=dragImport.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from '@volar/language-service';
|
|
2
2
|
export * from '@vue/language-core';
|
|
3
3
|
export * from './ideFeatures/nameCasing';
|
|
4
|
+
export * from './ideFeatures/dragImport';
|
|
4
5
|
export * from './languageService';
|
|
5
6
|
export { TagNameCasing, AttrNameCasing } from './types';
|
|
6
7
|
export { Provide } from './plugins/vue';
|
package/out/index.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.AttrNameCasing = exports.TagNameCasing = void 0;
|
|
|
18
18
|
__exportStar(require("@volar/language-service"), exports);
|
|
19
19
|
__exportStar(require("@vue/language-core"), exports);
|
|
20
20
|
__exportStar(require("./ideFeatures/nameCasing"), exports);
|
|
21
|
+
__exportStar(require("./ideFeatures/dragImport"), exports);
|
|
21
22
|
__exportStar(require("./languageService"), exports);
|
|
22
23
|
var types_1 = require("./types");
|
|
23
24
|
Object.defineProperty(exports, "TagNameCasing", { enumerable: true, get: function () { return types_1.TagNameCasing; } });
|
package/out/languageService.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import * as JsonService from 'volar-service-json';
|
|
|
5
5
|
export interface Settings {
|
|
6
6
|
json?: Parameters<typeof JsonService['create']>[0];
|
|
7
7
|
}
|
|
8
|
-
export declare function resolveConfig(config: Config, compilerOptions?: ts.CompilerOptions, vueCompilerOptions?: Partial<VueCompilerOptions>,
|
|
8
|
+
export declare function resolveConfig(ts: typeof import('typescript/lib/tsserverlibrary'), config: Config, compilerOptions?: ts.CompilerOptions, vueCompilerOptions?: Partial<VueCompilerOptions>, codegenStack?: boolean): Config;
|
|
9
9
|
//# sourceMappingURL=languageService.d.ts.map
|
package/out/languageService.js
CHANGED
|
@@ -26,9 +26,9 @@ const VueTemplateLanguageService = require("./plugins/vue-template");
|
|
|
26
26
|
const ToggleVBindService = require("./plugins/vue-toggle-v-bind-codeaction");
|
|
27
27
|
const VueTqService = require("./plugins/vue-twoslash-queries");
|
|
28
28
|
const VisualizeHiddenCallbackParamService = require("./plugins/vue-visualize-hidden-callback-param");
|
|
29
|
-
function resolveConfig(config, compilerOptions = {}, vueCompilerOptions = {},
|
|
29
|
+
function resolveConfig(ts, config, compilerOptions = {}, vueCompilerOptions = {}, codegenStack = false) {
|
|
30
30
|
const resolvedVueCompilerOptions = (0, language_core_1.resolveVueCompilerOptions)(vueCompilerOptions);
|
|
31
|
-
const vueLanguageModules = (0, language_core_1.createLanguages)(compilerOptions, resolvedVueCompilerOptions,
|
|
31
|
+
const vueLanguageModules = (0, language_core_1.createLanguages)(ts, compilerOptions, resolvedVueCompilerOptions, codegenStack);
|
|
32
32
|
config.languages = Object.assign({}, vueLanguageModules, config.languages);
|
|
33
33
|
config.services = resolvePlugins(config.services, resolvedVueCompilerOptions);
|
|
34
34
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Service } from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
export declare const create: () => Service;
|
|
4
|
+
export declare function getLastImportNode(ts: typeof import('typescript/lib/tsserverlibrary'), sourceFile: ts.SourceFile): ts.Node | undefined;
|
|
4
5
|
export declare function createAddComponentToOptionEdit(ts: typeof import('typescript/lib/tsserverlibrary'), ast: ts.SourceFile, componentName: string): {
|
|
5
6
|
range: import("@vue/language-core").TextRange;
|
|
6
7
|
newText: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAddComponentToOptionEdit = exports.create = void 0;
|
|
3
|
+
exports.createAddComponentToOptionEdit = exports.getLastImportNode = exports.create = void 0;
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
5
|
const unicodeReg = /\\u/g;
|
|
6
6
|
const create = function () {
|
|
@@ -56,7 +56,7 @@ const create = function () {
|
|
|
56
56
|
const toExtract = collectExtractProps();
|
|
57
57
|
const initialIndentSetting = await ctx.env.getConfiguration('volar.format.initialIndent');
|
|
58
58
|
const newUri = document.uri.substring(0, document.uri.lastIndexOf('/') + 1) + `${newName}.vue`;
|
|
59
|
-
const lastImportNode = getLastImportNode(script.ast);
|
|
59
|
+
const lastImportNode = getLastImportNode(ts, script.ast);
|
|
60
60
|
let newFileTags = [];
|
|
61
61
|
newFileTags.push(constructTag('template', [], initialIndentSetting.html, sfc.template.content.substring(templateCodeRange[0], templateCodeRange[1])));
|
|
62
62
|
if (toExtract.length) {
|
|
@@ -131,18 +131,6 @@ const create = function () {
|
|
|
131
131
|
],
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
|
-
function getLastImportNode(sourceFile) {
|
|
135
|
-
let lastImportNode;
|
|
136
|
-
for (const statement of sourceFile.statements) {
|
|
137
|
-
if (ts.isImportDeclaration(statement)) {
|
|
138
|
-
lastImportNode = statement;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return lastImportNode;
|
|
145
|
-
}
|
|
146
134
|
function collectExtractProps() {
|
|
147
135
|
const result = new Map();
|
|
148
136
|
const checker = languageService.getProgram().getTypeChecker();
|
|
@@ -253,6 +241,19 @@ function isInitialIndentNeeded(ts, languageKind, initialIndentSetting) {
|
|
|
253
241
|
};
|
|
254
242
|
return initialIndentSetting[languageKindIdMap[languageKind]] ?? false;
|
|
255
243
|
}
|
|
244
|
+
function getLastImportNode(ts, sourceFile) {
|
|
245
|
+
let lastImportNode;
|
|
246
|
+
for (const statement of sourceFile.statements) {
|
|
247
|
+
if (ts.isImportDeclaration(statement)) {
|
|
248
|
+
lastImportNode = statement;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return lastImportNode;
|
|
255
|
+
}
|
|
256
|
+
exports.getLastImportNode = getLastImportNode;
|
|
256
257
|
function createAddComponentToOptionEdit(ts, ast, componentName) {
|
|
257
258
|
const exportDefault = language_core_1.scriptRanges.parseScriptRanges(ts, ast, false, true).exportDefault;
|
|
258
259
|
if (!exportDefault)
|
package/out/types.d.ts
CHANGED
package/out/types.js
CHANGED
|
@@ -26,6 +26,6 @@ var AttrNameCasing;
|
|
|
26
26
|
AttrNameCasing[AttrNameCasing["Camel"] = 1] = "Camel";
|
|
27
27
|
})(AttrNameCasing || (exports.AttrNameCasing = AttrNameCasing = {}));
|
|
28
28
|
// only export types of depend packages
|
|
29
|
-
__exportStar(require("@volar/language-service/
|
|
29
|
+
__exportStar(require("@volar/language-service/lib/types"), exports);
|
|
30
30
|
__exportStar(require("@vue/language-core/out/types"), exports);
|
|
31
31
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-service",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.24",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,28 +17,31 @@
|
|
|
17
17
|
"update-html-data": "node ./scripts/update-html-data.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "~1.
|
|
21
|
-
"@volar/language-service": "~1.
|
|
22
|
-
"@volar/typescript": "~1.
|
|
20
|
+
"@volar/language-core": "~1.11.1",
|
|
21
|
+
"@volar/language-service": "~1.11.1",
|
|
22
|
+
"@volar/typescript": "~1.11.1",
|
|
23
23
|
"@vue/compiler-dom": "^3.3.0",
|
|
24
|
-
"@vue/language-core": "1.8.
|
|
24
|
+
"@vue/language-core": "1.8.24",
|
|
25
25
|
"@vue/shared": "^3.3.0",
|
|
26
26
|
"computeds": "^0.0.1",
|
|
27
|
-
"
|
|
28
|
-
"volar-service-
|
|
29
|
-
"volar-service-
|
|
30
|
-
"volar-service-
|
|
31
|
-
"volar-service-
|
|
32
|
-
"volar-service-pug
|
|
33
|
-
"volar-service-
|
|
34
|
-
"volar-service-typescript
|
|
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",
|
|
35
36
|
"vscode-html-languageservice": "^5.1.0",
|
|
36
37
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
+
"@types/node": "latest",
|
|
41
|
+
"@types/path-browserify": "latest",
|
|
42
|
+
"@volar/kit": "~1.11.1",
|
|
40
43
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
41
44
|
"vscode-uri": "^3.0.8"
|
|
42
45
|
},
|
|
43
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "6f850196d6b9cd1bee62104d3d92867cf0b6777e"
|
|
44
47
|
}
|