vscode-vue-languageservice
Advanced tools
Comparing version 0.27.27 to 0.27.28
@@ -157,3 +157,3 @@ "use strict"; | ||
const start = codeGen.getText().length; | ||
codeGen.addText(`export default __VLS_defineComponent({\n`); | ||
codeGen.addText(`export default (await import('./__VLS_types')).defineComponent({\n`); | ||
overlapMapRanges.push({ | ||
@@ -166,3 +166,3 @@ start, | ||
codeGen.addText(`\n`); | ||
codeGen.addText(`export const __VLS_component = __VLS_defineComponent({\n`); | ||
codeGen.addText(`export const __VLS_component = (await import('./__VLS_types')).defineComponent({\n`); | ||
} | ||
@@ -179,7 +179,7 @@ if (script && ((_a = scriptRanges === null || scriptRanges === void 0 ? void 0 : scriptRanges.exportDefault) === null || _a === void 0 ? void 0 : _a.args)) { | ||
if (scriptSetupRanges.withDefaultsArg) | ||
codeGen.addText(`__VLS_mergePropDefaults(`); | ||
codeGen.addText(`(await import('./__VLS_types')).mergePropDefaults(`); | ||
if (scriptSetupRanges.propsRuntimeArg) | ||
mapSubText('scriptSetup', scriptSetupRanges.propsRuntimeArg.start, scriptSetupRanges.propsRuntimeArg.end); | ||
else if (scriptSetupRanges.propsTypeArg) { | ||
codeGen.addText(`{} as __VLS_DefinePropsToOptions<`); | ||
codeGen.addText(`{} as import('./__VLS_types').DefinePropsToOptions<`); | ||
mapSubText('scriptSetup', scriptSetupRanges.propsTypeArg.start, scriptSetupRanges.propsTypeArg.end); | ||
@@ -201,3 +201,3 @@ codeGen.addText(`>`); | ||
else if (scriptSetupRanges.emitsTypeArg) { | ||
codeGen.addText(`emits: ({} as __VLS_ConstructorOverloads<`); | ||
codeGen.addText(`emits: ({} as import('./__VLS_types').ConstructorOverloads<`); | ||
mapSubText('scriptSetup', scriptSetupRanges.emitsTypeArg.start, scriptSetupRanges.emitsTypeArg.end); | ||
@@ -366,3 +366,3 @@ codeGen.addText(`>),\n`); | ||
const args = scriptRanges.exportDefault.args; | ||
codeGen.addText(`export const __VLS_name = __VLS_getNameOption(`); | ||
codeGen.addText(`export const __VLS_name = (await import('./__VLS_types')).getNameOption(`); | ||
codeGen.addText(`${script.content.substring(args.start, args.end)} as const`); | ||
@@ -369,0 +369,0 @@ codeGen.addText(`);\n`); |
@@ -58,2 +58,3 @@ import * as SourceMaps from '../utils/sourceMaps'; | ||
rawComponent: string; | ||
slotsComponent: string; | ||
baseProps: string; | ||
@@ -60,0 +61,0 @@ emit: string; |
@@ -71,4 +71,7 @@ import type * as vscode from 'vscode-languageserver'; | ||
onInitProgress(cb: (p: number) => void): void; | ||
checkProject: () => Promise<boolean>; | ||
getGlobalDoc: (lsType: 'script' | 'template') => TextDocument; | ||
getGlobalDoc: (lsType: 'script' | 'template') => TextDocument | undefined; | ||
getLocalTypesFiles: () => { | ||
fileNames: string[]; | ||
code: string; | ||
}; | ||
getContext: () => Promise<ApiLanguageServiceContext>; | ||
@@ -75,0 +78,0 @@ getD3: (document: TextDocument) => Promise<Promise<string>>; |
@@ -7,3 +7,4 @@ "use strict"; | ||
const sourceFile_1 = require("./sourceFile"); | ||
const globalDoc_1 = require("./utils/globalDoc"); | ||
const globalTypes = require("./utils/globalTypes"); | ||
const localTypes = require("./utils/localTypes"); | ||
const upath = require("upath"); | ||
@@ -129,4 +130,5 @@ const tsPluginApis = require("./tsPluginApis"); | ||
const scriptTsLs = ts2.createLanguageService(ts, scriptTsHost, scriptTsLsRaw); | ||
const scriptLsGlobalDoc = (0, globalDoc_1.createGlobalDefineDocument)(vueHost.getCurrentDirectory(), 'script'); | ||
const templateLsGlobalDoc = (0, globalDoc_1.createGlobalDefineDocument)(vueHost.getCurrentDirectory(), 'template'); | ||
const localTypesScript = ts.ScriptSnapshot.fromString(localTypes.code); | ||
const localTypesScriptName = '__VLS_types.ts'; | ||
const templateLsGlobalDoc = vscode_languageserver_textdocument_1.TextDocument.create(shared.fsPathToUri(upath.join(vueHost.getCurrentDirectory(), '__VLS_globals.ts')), 'typescript', 0, globalTypes.code); | ||
const compilerHost = ts.createCompilerHost(vueHost.getCompilationSettings()); | ||
@@ -243,7 +245,11 @@ const documentContext = { | ||
}, | ||
checkProject: publicApiHook(() => { | ||
const vueImportErrors = scriptTsLs.doValidation(scriptLsGlobalDoc.uri, { semantic: true }); | ||
return !vueImportErrors.find(error => error.code === 2322); // Type 'false' is not assignable to type 'true'.ts(2322) | ||
}, false), | ||
getGlobalDoc, | ||
getLocalTypesFiles: () => { | ||
const fileNames = getLocalTypesFiles(); | ||
const code = localTypes.code; | ||
return { | ||
fileNames, | ||
code, | ||
}; | ||
}, | ||
getContext: publicApiHook(() => context), | ||
@@ -256,4 +262,7 @@ getD3: publicApiHook(d3.register(context)), | ||
}; | ||
function getLocalTypesFiles() { | ||
return sourceFiles.getDirs().map(dir => upath.join(dir, localTypesScriptName)); | ||
} | ||
function getGlobalDoc(lsType) { | ||
return lsType === 'script' ? scriptLsGlobalDoc : templateLsGlobalDoc; | ||
return lsType === 'template' ? templateLsGlobalDoc : undefined; | ||
} | ||
@@ -490,4 +499,6 @@ function createTsPluginProxy() { | ||
function getScriptFileNames() { | ||
const tsFileNames = []; | ||
tsFileNames.push(shared.uriToFsPath(getGlobalDoc(lsType).uri)); | ||
const tsFileNames = getLocalTypesFiles(); | ||
const globalDoc = getGlobalDoc(lsType); | ||
if (globalDoc) | ||
tsFileNames.push(shared.uriToFsPath(globalDoc.uri)); | ||
for (const [tsUri] of sourceFiles.getTsDocuments(lsType)) { | ||
@@ -508,5 +519,8 @@ tsFileNames.push(shared.uriToFsPath(tsUri)); // virtual .ts | ||
const uri = shared.fsPathToUri(fileName); | ||
if (uri === getGlobalDoc(lsType).uri) { | ||
return getGlobalDoc(lsType).version.toString(); | ||
if (uri === templateLsGlobalDoc.uri) { | ||
return templateLsGlobalDoc.version.toString(); | ||
} | ||
if (upath.basename(fileName) === localTypesScriptName) { | ||
return '0'; | ||
} | ||
let doc = sourceFiles.getTsDocuments(lsType).get(uri); | ||
@@ -525,4 +539,4 @@ if (doc) { | ||
const uri = shared.fsPathToUri(fileName); | ||
if (uri === getGlobalDoc(lsType).uri) { | ||
const text = getGlobalDoc(lsType).getText(); | ||
if (uri === templateLsGlobalDoc.uri) { | ||
const text = templateLsGlobalDoc.getText(); | ||
const snapshot = ts.ScriptSnapshot.fromString(text); | ||
@@ -532,2 +546,5 @@ scriptSnapshots.set(fileName, [version, snapshot]); | ||
} | ||
if (upath.basename(fileName) === localTypesScriptName) { | ||
return localTypesScript; | ||
} | ||
const doc = sourceFiles.getTsDocuments(lsType).get(uri); | ||
@@ -534,0 +551,0 @@ if (doc) { |
@@ -10,2 +10,3 @@ import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
rawComponent: string; | ||
slotsComponent: string; | ||
baseProps: string; | ||
@@ -406,2 +407,3 @@ emit: string; | ||
rawComponent: string; | ||
slotsComponent: string; | ||
baseProps: string; | ||
@@ -408,0 +410,0 @@ emit: string; |
@@ -6,2 +6,4 @@ "use strict"; | ||
const untrack_1 = require("./utils/untrack"); | ||
const shared = require("@volar/shared"); | ||
const path = require("upath"); | ||
function createSourceFiles() { | ||
@@ -117,4 +119,6 @@ const sourceFiles = (0, reactivity_1.shallowReactive)({}); | ||
}; | ||
const dirs = (0, reactivity_1.computed)(() => [...new Set(uris.value.map(shared.uriToFsPath).map(path.dirname))]); | ||
return { | ||
getUris: (0, untrack_1.untrack)(() => uris.value), | ||
getDirs: (0, untrack_1.untrack)(() => dirs.value), | ||
getAll: (0, untrack_1.untrack)(() => all.value), | ||
@@ -121,0 +125,0 @@ get: (0, untrack_1.untrack)((uri) => sourceFiles[uri.toLowerCase()]), |
@@ -18,2 +18,3 @@ "use strict"; | ||
content += '// @ts-nocheck\n'; | ||
content += `import * as __VLS_types from './__VLS_types';\n`; | ||
if (scriptSetup.value || script.value) { | ||
@@ -34,4 +35,4 @@ content += `import { __VLS_options as __VLS_options_ts, __VLS_name as __VLS_name_ts } from './${vueFileName}.${tsScriptFileName}';\n`; | ||
content += `import { __VLS_component as __VLS_component_2 } from './${vueFileName}.__VLS_script';\n`; | ||
content += `declare var __VLS_component_ts: __VLS_SelectComponent<typeof __VLS_component_1_ts, typeof __VLS_component_2_ts>;\n`; | ||
content += `export declare var __VLS_component: __VLS_SelectComponent<typeof __VLS_component_1, typeof __VLS_component_2>;\n`; | ||
content += `declare var __VLS_component_ts: __VLS_types.SelectComponent<typeof __VLS_component_1_ts, typeof __VLS_component_2_ts>;\n`; | ||
content += `export declare var __VLS_component: __VLS_types.SelectComponent<typeof __VLS_component_1, typeof __VLS_component_2>;\n`; | ||
} | ||
@@ -42,13 +43,13 @@ } | ||
content += `export var __VLS_name = undefined;\n`; | ||
content += `var __VLS_component_ts = __VLS_defineComponent({});\n`; | ||
content += `export var __VLS_component = __VLS_defineComponent({});\n`; | ||
content += `var __VLS_component_ts = __VLS_types.defineComponent({});\n`; | ||
content += `export var __VLS_component = __VLS_types.defineComponent({});\n`; | ||
} | ||
content += `declare var __VLS_ctx: __VLS_ComponentContext<typeof __VLS_component_ts>;\n`; | ||
content += `declare var __VLS_ctx: __VLS_types.ComponentContext<typeof __VLS_component_ts>;\n`; | ||
content += `declare var __VLS_ComponentsWrap: typeof __VLS_options & { components: { } };\n`; | ||
content += `declare var __VLS_Components: typeof __VLS_ComponentsWrap.components & __VLS_GlobalComponents & __VLS_PickComponents<typeof __VLS_ctx> & __VLS_SelfComponent<typeof __VLS_name, typeof __VLS_component>;\n`; | ||
content += `declare var __VLS_Components: typeof __VLS_ComponentsWrap.components & __VLS_types.GlobalComponents & __VLS_types.PickComponents<typeof __VLS_ctx> & __VLS_types.SelfComponent<typeof __VLS_name, typeof __VLS_component>;\n`; | ||
content += `__VLS_ctx.${string_1.SearchTexts.Context};\n`; | ||
content += `__VLS_Components.${string_1.SearchTexts.Components};\n`; | ||
content += `({} as __VLS_OptionsSetupReturns<typeof __VLS_options_ts>).${string_1.SearchTexts.SetupReturns};\n`; | ||
content += `({} as __VLS_OptionsProps<typeof __VLS_options_ts>).${string_1.SearchTexts.Props};\n`; | ||
content += `({} as __VLS_GlobalAttrs).${string_1.SearchTexts.GlobalAttrs};`; | ||
content += `({} as __VLS_types.OptionsSetupReturns<typeof __VLS_options_ts>).${string_1.SearchTexts.SetupReturns};\n`; | ||
content += `({} as __VLS_types.OptionsProps<typeof __VLS_options_ts>).${string_1.SearchTexts.Props};\n`; | ||
content += `({} as __VLS_types.GlobalAttrs).${string_1.SearchTexts.GlobalAttrs};`; | ||
content += `\n`; | ||
@@ -55,0 +56,0 @@ content += `export default {} as typeof __VLS_component & {\n`; |
@@ -76,2 +76,3 @@ import * as shared from '@volar/shared'; | ||
rawComponent: string; | ||
slotsComponent: string; | ||
baseProps: string; | ||
@@ -78,0 +79,0 @@ emit: string; |
@@ -32,12 +32,13 @@ "use strict"; | ||
const codeGen = (0, code_gen_1.createCodeGen)(); | ||
codeGen.addText(`import * as __VLS_types from './__VLS_types';\n`); | ||
codeGen.addText(`import { __VLS_options, __VLS_name, __VLS_component } from './${vueFileName}';\n`); | ||
writeImportTypes(); | ||
codeGen.addText(`declare var __VLS_ctxRaw: InstanceType<typeof __VLS_component>;\n`); | ||
codeGen.addText(`declare var __VLS_ctx: __VLS_ExtractRawComponents<typeof __VLS_ctxRaw>;\n`); | ||
codeGen.addText(`declare var __VLS_ctx: __VLS_types.ExtractRawComponents<typeof __VLS_ctxRaw>;\n`); | ||
codeGen.addText(`declare var __VLS_vmUnwrap: typeof __VLS_options & { components: { } };\n`); | ||
/* Components */ | ||
codeGen.addText('/* Components */\n'); | ||
codeGen.addText('declare var __VLS_ownComponent: __VLS_SelfComponent<typeof __VLS_name, typeof __VLS_component & { __VLS_raw: typeof __VLS_component, __VLS_options: typeof __VLS_options, __VLS_slots: typeof __VLS_slots }>;\n'); | ||
codeGen.addText('declare var __VLS_wrapComponents: __VLS_GlobalComponents & typeof __VLS_vmUnwrap.components & __VLS_PickComponents<typeof __VLS_ctxRaw> & typeof __VLS_ownComponent;\n'); // has __VLS_options | ||
codeGen.addText('declare var __VLS_rawComponents: __VLS_ExtractRawComponents<typeof __VLS_wrapComponents> & JSX.IntrinsicElements;\n'); // sort by priority | ||
codeGen.addText('declare var __VLS_ownComponent: __VLS_types.SelfComponent<typeof __VLS_name, typeof __VLS_component & { __VLS_raw: typeof __VLS_component, __VLS_options: typeof __VLS_options, __VLS_slots: typeof __VLS_slots }>;\n'); | ||
codeGen.addText('declare var __VLS_wrapComponents: __VLS_types.GlobalComponents & typeof __VLS_vmUnwrap.components & __VLS_types.PickComponents<typeof __VLS_ctxRaw> & typeof __VLS_ownComponent;\n'); // has __VLS_options | ||
codeGen.addText('declare var __VLS_rawComponents: __VLS_types.ExtractRawComponents<typeof __VLS_wrapComponents> & JSX.IntrinsicElements;\n'); // sort by priority | ||
/* CSS Module */ | ||
@@ -44,0 +45,0 @@ codeGen.addText('/* CSS Module */\n'); |
{ | ||
"name": "vscode-vue-languageservice", | ||
"version": "0.27.27", | ||
"version": "0.27.28", | ||
"main": "out/index.js", | ||
@@ -38,3 +38,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "6cb316dfd5b7c0d64277c7bdf36d067349ee07e1" | ||
"gitHead": "6eaf1d3e5678d40de6ac51b1db8c3888d74957ff" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
706675
145
14602