@vue/language-service 1.8.22 → 1.8.25

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.
@@ -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 <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"
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": [
@@ -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 <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"
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; } });
@@ -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>, ts?: typeof import('typescript/lib/tsserverlibrary'), codegenStack?: boolean): Config;
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
@@ -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 = {}, ts = require('typescript'), codegenStack = false) {
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, ts, codegenStack);
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;
@@ -0,0 +1,3 @@
1
+ import { ServicePlugin } from '../types';
2
+ export declare function create(ts: typeof import('typescript/lib/tsserverlibrary')): ServicePlugin;
3
+ //# sourceMappingURL=vue-document-drop.d.ts.map
@@ -0,0 +1,83 @@
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 shared_1 = require("@vue/shared");
6
+ const path = require("path-browserify");
7
+ const vue_extract_file_1 = require("../plugins/vue-extract-file");
8
+ const types_1 = require("../types");
9
+ function create(ts) {
10
+ return {
11
+ create(context) {
12
+ let casing = types_1.TagNameCasing.Pascal; // TODO
13
+ return {
14
+ async provideDocumentDropEdits(document, _position, dataTransfer) {
15
+ if (document.languageId !== 'html')
16
+ return;
17
+ const [virtualFile, sourceFile] = context.language.files.getVirtualFile(document.uri);
18
+ const vueFile = sourceFile?.virtualFile?.[0];
19
+ if (!virtualFile || !(vueFile instanceof language_core_1.VueFile))
20
+ return;
21
+ let importUri;
22
+ for (const [mimeType, item] of dataTransfer) {
23
+ if (mimeType === 'text/uri-list') {
24
+ importUri = item.value;
25
+ }
26
+ }
27
+ if (!importUri?.endsWith('.vue'))
28
+ return;
29
+ let baseName = importUri.substring(importUri.lastIndexOf('/') + 1);
30
+ baseName = baseName.substring(0, baseName.lastIndexOf('.'));
31
+ const newName = (0, shared_1.capitalize)((0, shared_1.camelize)(baseName));
32
+ let additionalEdit;
33
+ for (const file of (0, language_core_1.forEachEmbeddedFile)(vueFile)) {
34
+ if ((file.languageId === 'typescript'
35
+ || file.languageId === 'javascript'
36
+ || file.languageId === 'typescriptreact'
37
+ || file.languageId === 'javascriptreact')
38
+ && file.mappings.some(mapping => (0, language_core_1.isFoldingRangesEnabled)(mapping.data))) {
39
+ additionalEdit ??= {};
40
+ additionalEdit.changes ??= {};
41
+ additionalEdit.changes[file.id] = [];
42
+ const { sfc } = vueFile;
43
+ const script = sfc.scriptSetup ?? sfc.script;
44
+ if (!sfc.template || !script)
45
+ return;
46
+ const lastImportNode = (0, vue_extract_file_1.getLastImportNode)(ts, script.ast);
47
+ additionalEdit.changes[file.id].push({
48
+ range: lastImportNode ? {
49
+ start: document.positionAt(lastImportNode.end),
50
+ end: document.positionAt(lastImportNode.end),
51
+ } : {
52
+ start: document.positionAt(0),
53
+ end: document.positionAt(0),
54
+ },
55
+ newText: `\nimport ${newName} from './${path.relative(path.dirname(document.uri), importUri) || importUri.substring(importUri.lastIndexOf('/') + 1)}'`
56
+ + (lastImportNode ? '' : '\n'),
57
+ });
58
+ if (sfc.script) {
59
+ const edit = (0, vue_extract_file_1.createAddComponentToOptionEdit)(ts, sfc.script.ast, newName);
60
+ if (edit) {
61
+ additionalEdit.changes[file.id].push({
62
+ range: {
63
+ start: document.positionAt(edit.range.start),
64
+ end: document.positionAt(edit.range.end),
65
+ },
66
+ newText: edit.newText,
67
+ });
68
+ }
69
+ }
70
+ }
71
+ }
72
+ return {
73
+ insertText: `<${casing === types_1.TagNameCasing.Kebab ? (0, shared_1.hyphenate)(newName) : newName}$0 />`,
74
+ insertTextFormat: 2,
75
+ additionalEdit,
76
+ };
77
+ },
78
+ };
79
+ },
80
+ };
81
+ }
82
+ exports.create = create;
83
+ //# sourceMappingURL=vue-document-drop.js.map
@@ -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
@@ -6,6 +6,6 @@ export declare enum AttrNameCasing {
6
6
  Kebab = 0,
7
7
  Camel = 1
8
8
  }
9
- export * from '@volar/language-service/out/types';
9
+ export * from '@volar/language-service/lib/types';
10
10
  export * from '@vue/language-core/out/types';
11
11
  //# sourceMappingURL=types.d.ts.map
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/out/types"), exports);
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.22",
3
+ "version": "1.8.25",
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.10.5",
21
- "@volar/language-service": "~1.10.5",
22
- "@volar/typescript": "~1.10.5",
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.22",
24
+ "@vue/language-core": "1.8.25",
25
25
  "@vue/shared": "^3.3.0",
26
26
  "computeds": "^0.0.1",
27
- "volar-service-css": "0.0.15",
28
- "volar-service-emmet": "0.0.15",
29
- "volar-service-html": "0.0.15",
30
- "volar-service-json": "0.0.15",
31
- "volar-service-pug": "0.0.15",
32
- "volar-service-pug-beautify": "0.0.15",
33
- "volar-service-typescript": "0.0.15",
34
- "volar-service-typescript-twoslash-queries": "0.0.15",
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
- "@volar/kit": "~1.10.5",
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": "1e8d09af0282c42dd816671ffcd5a2321276e3c3"
46
+ "gitHead": "6f8ca45025b8e38a86f6946bbc294a6a2d88b063"
44
47
  }