@vue/typescript-plugin
Advanced tools
Comparing version
import type { RequestContext } from './types'; | ||
export declare function collectExtractProps(this: RequestContext, fileName: string, templateCodeRange: [number, number]): { | ||
interface ExtractPropsInfo { | ||
name: string; | ||
type: string; | ||
model: boolean; | ||
}[] | undefined; | ||
} | ||
export declare function collectExtractProps(this: RequestContext, fileName: string, templateCodeRange: [number, number]): ExtractPropsInfo[]; | ||
export {}; |
@@ -8,9 +8,6 @@ "use strict"; | ||
const sourceScript = language.scripts.get(fileName); | ||
if (!sourceScript?.generated) { | ||
return; | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const root = sourceScript.generated.root; | ||
if (!(root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
} | ||
const result = new Map(); | ||
@@ -20,4 +17,4 @@ const program = languageService.getProgram(); | ||
const checker = program.getTypeChecker(); | ||
const script = sourceScript.generated?.languagePlugin.typescript?.getServiceScript(root); | ||
const maps = script ? [...language.maps.forEach(script.code)].map(([_sourceScript, map]) => map) : []; | ||
const script = sourceScript.generated.languagePlugin.typescript?.getServiceScript(root); | ||
const maps = script ? [...language.maps.forEach(script.code)].map(([, map]) => map) : []; | ||
const { sfc } = root; | ||
@@ -24,0 +21,0 @@ sourceFile.forEachChild(function visit(node) { |
import type { RequestContext } from './types'; | ||
export declare function getComponentDirectives(this: RequestContext, fileName: string): string[] | undefined; | ||
export declare function getComponentDirectives(this: RequestContext, fileName: string): string[]; |
@@ -16,8 +16,8 @@ "use strict"; | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
const directives = (0, utils_1.getVariableType)(ts, languageService, vueCode, '__VLS_directives'); | ||
const directives = (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_directives'); | ||
if (!directives) { | ||
@@ -24,0 +24,0 @@ return []; |
import type { RequestContext } from './types'; | ||
export declare function getComponentEvents(this: RequestContext, fileName: string, tag: string): string[] | undefined; | ||
export declare function getComponentEvents(this: RequestContext, fileName: string, tag: string): string[]; |
@@ -8,14 +8,14 @@ "use strict"; | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
const program = languageService.getProgram(); | ||
const checker = program.getTypeChecker(); | ||
const components = (0, utils_1.getVariableType)(ts, languageService, vueCode, '__VLS_components'); | ||
const components = (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_components'); | ||
if (!components) { | ||
return []; | ||
} | ||
const componentType = (0, utils_1.getComponentType)(ts, languageService, vueCode, components, fileName, tag); | ||
const componentType = (0, utils_1.getComponentType)(ts, languageService, root, components, fileName, tag); | ||
if (!componentType) { | ||
@@ -22,0 +22,0 @@ return []; |
@@ -1,5 +0,2 @@ | ||
import { VueVirtualCode } from '@vue/language-core'; | ||
import type * as ts from 'typescript'; | ||
import type { RequestContext } from './types'; | ||
export declare function getComponentNames(this: RequestContext, fileName: string): string[] | undefined; | ||
export declare function _getComponentNames(ts: typeof import('typescript'), tsLs: ts.LanguageService, vueCode: VueVirtualCode): string[]; | ||
export declare function getComponentNames(this: RequestContext, fileName: string): string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getComponentNames = getComponentNames; | ||
exports._getComponentNames = _getComponentNames; | ||
const language_core_1 = require("@vue/language-core"); | ||
@@ -9,11 +8,8 @@ const utils_1 = require("./utils"); | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
return _getComponentNames(ts, languageService, vueCode); | ||
} | ||
function _getComponentNames(ts, tsLs, vueCode) { | ||
const names = (0, utils_1.getVariableType)(ts, tsLs, vueCode, '__VLS_components') | ||
const names = (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_components') | ||
?.type | ||
@@ -24,5 +20,5 @@ ?.getProperties() | ||
?? []; | ||
names.push((0, utils_1.getSelfComponentName)(vueCode.fileName)); | ||
names.push((0, utils_1.getSelfComponentName)(fileName)); | ||
return names; | ||
} | ||
//# sourceMappingURL=getComponentNames.js.map |
@@ -10,2 +10,2 @@ import type { RequestContext } from './types'; | ||
} | ||
export declare function getComponentProps(this: RequestContext, fileName: string, tag: string): ComponentPropInfo[] | undefined; | ||
export declare function getComponentProps(this: RequestContext, fileName: string, tag: string): ComponentPropInfo[]; |
@@ -8,12 +8,12 @@ "use strict"; | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
const components = (0, utils_1.getVariableType)(ts, languageService, vueCode, '__VLS_components'); | ||
const components = (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_components'); | ||
if (!components) { | ||
return []; | ||
} | ||
const componentType = (0, utils_1.getComponentType)(ts, languageService, vueCode, components, fileName, tag); | ||
const componentType = (0, utils_1.getComponentType)(ts, languageService, root, components, fileName, tag); | ||
if (!componentType) { | ||
@@ -20,0 +20,0 @@ return []; |
import type { RequestContext } from './types'; | ||
export declare function getComponentSlots(this: RequestContext, fileName: string): string[] | undefined; | ||
export declare function getComponentSlots(this: RequestContext, fileName: string): string[]; |
@@ -8,13 +8,13 @@ "use strict"; | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
const codegen = language_core_1.tsCodegen.get(vueCode.sfc); | ||
const codegen = language_core_1.tsCodegen.get(root.sfc); | ||
if (!codegen) { | ||
return; | ||
return []; | ||
} | ||
const assignName = codegen.getSetupSlotsAssignName() ?? `__VLS_slots`; | ||
const slots = (0, utils_1.getVariableType)(ts, languageService, vueCode, assignName); | ||
const slots = (0, utils_1.getVariableType)(ts, languageService, root, assignName); | ||
if (!slots) { | ||
@@ -21,0 +21,0 @@ return []; |
import type { RequestContext } from './types'; | ||
export declare function getElementAttrs(this: RequestContext, fileName: string, tagName: string): string[] | undefined; | ||
export declare function getElementAttrs(this: RequestContext, fileName: string, tagName: string): string[]; |
@@ -8,10 +8,10 @@ "use strict"; | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
const program = languageService.getProgram(); | ||
const checker = program.getTypeChecker(); | ||
const elements = (0, utils_1.getVariableType)(ts, languageService, vueCode, '__VLS_elements'); | ||
const elements = (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_elements'); | ||
if (!elements) { | ||
@@ -18,0 +18,0 @@ return []; |
@@ -1,5 +0,2 @@ | ||
import { VueVirtualCode } from '@vue/language-core'; | ||
import type * as ts from 'typescript'; | ||
import type { RequestContext } from './types'; | ||
export declare function getElementNames(this: RequestContext, fileName: string): string[] | undefined; | ||
export declare function _getElementNames(ts: typeof import('typescript'), tsLs: ts.LanguageService, vueCode: VueVirtualCode): string[]; | ||
export declare function getElementNames(this: RequestContext, fileName: string): string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getElementNames = getElementNames; | ||
exports._getElementNames = _getElementNames; | ||
const language_core_1 = require("@vue/language-core"); | ||
@@ -9,11 +8,8 @@ const utils_1 = require("./utils"); | ||
const { typescript: ts, language, languageService } = this; | ||
const volarFile = language.scripts.get(fileName); | ||
if (!(volarFile?.generated?.root instanceof language_core_1.VueVirtualCode)) { | ||
return; | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const vueCode = volarFile.generated.root; | ||
return _getElementNames(ts, languageService, vueCode); | ||
} | ||
function _getElementNames(ts, tsLs, vueCode) { | ||
return (0, utils_1.getVariableType)(ts, tsLs, vueCode, '__VLS_elements') | ||
return (0, utils_1.getVariableType)(ts, languageService, root, '__VLS_elements') | ||
?.type | ||
@@ -20,0 +16,0 @@ ?.getProperties() |
import type * as ts from 'typescript'; | ||
import type { RequestContext } from './types'; | ||
export declare function getImportPathForFile(this: RequestContext, fileName: string, incomingFileName: string, preferences: ts.UserPreferences): string | undefined; | ||
export declare function getImportPathForFile(this: RequestContext, fileName: string, incomingFileName: string, preferences: ts.UserPreferences): { | ||
path?: string; | ||
}; |
@@ -10,11 +10,11 @@ "use strict"; | ||
if (!program || !sourceFile || !incomingFile) { | ||
return; | ||
return {}; | ||
} | ||
const getModuleSpecifiersWithCacheInfo = ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo; | ||
const resolutionHost = ts.createModuleSpecifierResolutionHost(program, languageServiceHost); | ||
const moduleSpecifiers = getModuleSpecifiersWithCacheInfo(incomingFile.symbol, program.getTypeChecker(), languageServiceHost.getCompilationSettings(), sourceFile, resolutionHost, preferences); | ||
for (const moduleSpecifier of moduleSpecifiers.moduleSpecifiers) { | ||
return moduleSpecifier; | ||
} | ||
const { moduleSpecifiers } = getModuleSpecifiersWithCacheInfo(incomingFile.symbol, program.getTypeChecker(), languageServiceHost.getCompilationSettings(), sourceFile, resolutionHost, preferences); | ||
return { | ||
path: moduleSpecifiers[0], | ||
}; | ||
} | ||
//# sourceMappingURL=getImportPathForFile.js.map |
import type { RequestContext } from './types'; | ||
export declare function getPropertiesAtLocation(this: RequestContext, fileName: string, position: number): string[] | undefined; | ||
export declare function getPropertiesAtLocation(this: RequestContext, fileName: string, position: number): string[]; |
@@ -9,34 +9,36 @@ "use strict"; | ||
// mapping | ||
const file = language.scripts.get(fileName); | ||
if (file?.generated) { | ||
const virtualScript = file.generated.languagePlugin.typescript?.getServiceScript(file.generated.root); | ||
if (!virtualScript) { | ||
return; | ||
} | ||
let mapped = false; | ||
for (const [_sourceScript, map] of language.maps.forEach(virtualScript.code)) { | ||
for (const [position2, mapping] of map.toGeneratedLocation(position)) { | ||
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) { | ||
position = position2; | ||
mapped = true; | ||
break; | ||
} | ||
} | ||
if (mapped) { | ||
const sourceScript = language.scripts.get(fileName); | ||
const root = sourceScript?.generated?.root; | ||
if (!sourceScript?.generated || !(root instanceof language_core_1.VueVirtualCode)) { | ||
return []; | ||
} | ||
const virtualScript = sourceScript.generated.languagePlugin.typescript?.getServiceScript(root); | ||
if (!virtualScript) { | ||
return []; | ||
} | ||
let mapped = false; | ||
for (const [_sourceScript, map] of language.maps.forEach(virtualScript.code)) { | ||
for (const [position2, mapping] of map.toGeneratedLocation(position)) { | ||
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) { | ||
position = position2; | ||
mapped = true; | ||
break; | ||
} | ||
} | ||
if (!mapped) { | ||
return; | ||
if (mapped) { | ||
break; | ||
} | ||
position += file.snapshot.getLength(); | ||
} | ||
if (!mapped) { | ||
return []; | ||
} | ||
position += sourceScript.snapshot.getLength(); | ||
const program = languageService.getProgram(); | ||
const sourceFile = program.getSourceFile(fileName); | ||
if (!sourceFile) { | ||
return; | ||
return []; | ||
} | ||
const node = findPositionIdentifier(sourceFile, sourceFile, position); | ||
if (!node) { | ||
return; | ||
return []; | ||
} | ||
@@ -43,0 +45,0 @@ const checker = program.getTypeChecker(); |
import type * as ts from 'typescript'; | ||
type ToRequest<T extends (...args: any) => any> = (...args: Parameters<T>) => Promise<ReturnType<T> | null | undefined>; | ||
export type Requests = { | ||
collectExtractProps: ToRequest<typeof import('./collectExtractProps.js')['collectExtractProps']>; | ||
getImportPathForFile: ToRequest<typeof import('./getImportPathForFile.js')['getImportPathForFile']>; | ||
getPropertiesAtLocation: ToRequest<typeof import('./getPropertiesAtLocation.js')['getPropertiesAtLocation']>; | ||
getComponentDirectives: ToRequest<typeof import('./getComponentDirectives.js')['getComponentDirectives']>; | ||
getComponentEvents: ToRequest<typeof import('./getComponentEvents.js')['getComponentEvents']>; | ||
getComponentNames: ToRequest<typeof import('./getComponentNames.js')['getComponentNames']>; | ||
getComponentProps: ToRequest<typeof import('./getComponentProps.js')['getComponentProps']>; | ||
getComponentSlots: ToRequest<typeof import('./getComponentSlots.js')['getComponentSlots']>; | ||
getElementAttrs: ToRequest<typeof import('./getElementAttrs.js')['getElementAttrs']>; | ||
getElementNames: ToRequest<typeof import('./getElementNames.js')['getElementNames']>; | ||
getDocumentHighlights: ToRequest<(fileName: string, position: number) => ts.DocumentHighlights[]>; | ||
getEncodedSemanticClassifications: ToRequest<(fileName: string, span: ts.TextSpan) => ts.Classifications>; | ||
getQuickInfoAtPosition: ToRequest<(fileName: string, position: ts.LineAndCharacter) => string>; | ||
}; | ||
type Request<T extends (...args: any) => any> = (...args: Parameters<T>) => MaybePromise<ReturnType<T> | null | undefined>; | ||
type MaybePromise<T> = T | Promise<T>; | ||
export interface Requests { | ||
collectExtractProps: Request<typeof import('./collectExtractProps.js')['collectExtractProps']>; | ||
getImportPathForFile: Request<typeof import('./getImportPathForFile.js')['getImportPathForFile']>; | ||
getPropertiesAtLocation: Request<typeof import('./getPropertiesAtLocation.js')['getPropertiesAtLocation']>; | ||
getComponentDirectives: Request<typeof import('./getComponentDirectives.js')['getComponentDirectives']>; | ||
getComponentEvents: Request<typeof import('./getComponentEvents.js')['getComponentEvents']>; | ||
getComponentNames: Request<typeof import('./getComponentNames.js')['getComponentNames']>; | ||
getComponentProps: Request<typeof import('./getComponentProps.js')['getComponentProps']>; | ||
getComponentSlots: Request<typeof import('./getComponentSlots.js')['getComponentSlots']>; | ||
getElementAttrs: Request<typeof import('./getElementAttrs.js')['getElementAttrs']>; | ||
getElementNames: Request<typeof import('./getElementNames.js')['getElementNames']>; | ||
getDocumentHighlights: Request<(fileName: string, position: number) => ts.DocumentHighlights[]>; | ||
getEncodedSemanticClassifications: Request<(fileName: string, span: ts.TextSpan) => ts.Classifications>; | ||
getQuickInfoAtPosition: Request<(fileName: string, position: ts.LineAndCharacter) => string>; | ||
} | ||
export {}; |
{ | ||
"name": "@vue/typescript-plugin", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"license": "MIT", | ||
@@ -16,4 +16,4 @@ "files": [ | ||
"dependencies": { | ||
"@volar/typescript": "2.4.20", | ||
"@vue/language-core": "3.0.4", | ||
"@volar/typescript": "2.4.22", | ||
"@vue/language-core": "3.0.5", | ||
"@vue/shared": "^3.5.0", | ||
@@ -26,3 +26,3 @@ "path-browserify": "^1.0.1" | ||
}, | ||
"gitHead": "148d386f9779c2de64cdcbd35310e03b36943b05" | ||
"gitHead": "036b6b1882179d35586e16f2a5cba5150e5d18e6" | ||
} |
51803
1%49
4.26%1088
1.97%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated