vue-component-meta
Advanced tools
Comparing version 1.7.8 to 1.7.9
@@ -14,3 +14,9 @@ import * as vue from '@vue/language-core'; | ||
__internal__: { | ||
tsLs: ts.LanguageService; | ||
tsLs: { | ||
__internal__: { | ||
languageServiceHost: ts.LanguageServiceHost; | ||
languageService: ts.LanguageService; | ||
context: vue.LanguageContext; | ||
}; | ||
} & ts.LanguageService; | ||
}; | ||
@@ -26,11 +32,23 @@ }; | ||
__internal__: { | ||
tsLs: ts.LanguageService; | ||
tsLs: { | ||
__internal__: { | ||
languageServiceHost: ts.LanguageServiceHost; | ||
languageService: ts.LanguageService; | ||
context: vue.LanguageContext; | ||
}; | ||
} & ts.LanguageService; | ||
}; | ||
}; | ||
export declare function baseCreate(_host: vue.LanguageServiceHost, _vueCompilerOptions: Partial<vue.VueCompilerOptions>, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')): { | ||
export declare function baseCreate(_host: vue.TypeScriptLanguageHost, _vueCompilerOptions: Partial<vue.VueCompilerOptions>, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')): { | ||
getExportNames: (componentPath: string) => string[]; | ||
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta; | ||
__internal__: { | ||
tsLs: ts.LanguageService; | ||
tsLs: { | ||
__internal__: { | ||
languageServiceHost: ts.LanguageServiceHost; | ||
languageService: ts.LanguageService; | ||
context: vue.LanguageContext; | ||
}; | ||
} & ts.LanguageService; | ||
}; | ||
}; |
@@ -19,15 +19,17 @@ "use strict"; | ||
const vue = require("@vue/language-core"); | ||
const language_core_1 = require("@volar/language-core"); | ||
const path = require("typesafe-path/posix"); | ||
const vue_component_type_helpers_1 = require("vue-component-type-helpers"); | ||
const typescript_1 = require("@volar/typescript"); | ||
__exportStar(require("./types"), exports); | ||
function createComponentMetaCheckerByJsonConfig(root, json, checkerOptions = {}, ts = require('typescript')) { | ||
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLineByJson(ts, ts.sys, root, json), checkerOptions, path.join(root.replace(/\\/g, '/'), 'jsconfig.json.global.vue'), ts); | ||
const rootPath = root.replace(/\\/g, '/'); | ||
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLineByJson(ts, ts.sys, root, json), checkerOptions, rootPath, path.join(rootPath, 'jsconfig.json.global.vue'), ts); | ||
} | ||
exports.createComponentMetaCheckerByJsonConfig = createComponentMetaCheckerByJsonConfig; | ||
function createComponentMetaChecker(tsconfigPath, checkerOptions = {}, ts = require('typescript')) { | ||
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLine(ts, ts.sys, tsconfigPath), checkerOptions, tsconfigPath.replace(/\\/g, '/') + '.global.vue', ts); | ||
const tsconfig = tsconfigPath.replace(/\\/g, '/'); | ||
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLine(ts, ts.sys, tsconfigPath), checkerOptions, path.dirname(tsconfig), tsconfig + '.global.vue', ts); | ||
} | ||
exports.createComponentMetaChecker = createComponentMetaChecker; | ||
function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions, globalComponentName, ts) { | ||
function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions, rootPath, globalComponentName, ts) { | ||
/** | ||
@@ -40,12 +42,8 @@ * Original Host | ||
const scriptSnapshots = new Map(); | ||
const scriptVersions = new Map(); | ||
const _host = { | ||
...ts.sys, | ||
getProjectVersion: () => projectVersion.toString(), | ||
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), | ||
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, | ||
getCurrentDirectory: () => rootPath, | ||
getProjectVersion: () => projectVersion, | ||
getCompilationSettings: () => parsedCommandLine.options, | ||
getScriptFileNames: () => fileNames, | ||
getProjectReferences: () => parsedCommandLine.projectReferences, | ||
getScriptVersion: (fileName) => scriptVersions.get(fileName)?.toString() ?? '', | ||
getScriptSnapshot: (fileName) => { | ||
@@ -66,3 +64,2 @@ if (!scriptSnapshots.has(fileName)) { | ||
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text)); | ||
scriptVersions.set(fileName, scriptVersions.has(fileName) ? scriptVersions.get(fileName) + 1 : 1); | ||
projectVersion++; | ||
@@ -82,3 +79,2 @@ }, | ||
scriptSnapshots.clear(); | ||
scriptVersions.clear(); | ||
projectVersion++; | ||
@@ -125,5 +121,7 @@ }, | ||
const vueLanguages = ts ? vue.createLanguages(host.getCompilationSettings(), vueCompilerOptions, ts) : []; | ||
const core = (0, language_core_1.createLanguageContext)({ typescript: ts }, host, vueLanguages); | ||
const proxyApis = checkerOptions.forceUseTs ? { | ||
getScriptKind: (fileName) => { | ||
const core = vue.createLanguageContext(host, vueLanguages); | ||
const tsLs = (0, typescript_1.createLanguageService)(core, ts, ts.sys); | ||
if (checkerOptions.forceUseTs) { | ||
const getScriptKind = tsLs.__internal__.languageServiceHost.getScriptKind; | ||
tsLs.__internal__.languageServiceHost.getScriptKind = (fileName) => { | ||
if (fileName.endsWith('.vue.js')) { | ||
@@ -135,14 +133,5 @@ return ts.ScriptKind.TS; | ||
} | ||
return core.typescript.languageServiceHost.getScriptKind(fileName); | ||
}, | ||
} : {}; | ||
const proxyHost = new Proxy(core.typescript.languageServiceHost, { | ||
get(target, propKey) { | ||
if (propKey in proxyApis) { | ||
return proxyApis[propKey]; | ||
} | ||
return target[propKey]; | ||
} | ||
}); | ||
const tsLs = ts.createLanguageService(proxyHost); | ||
return getScriptKind(fileName); | ||
}; | ||
} | ||
let globalPropNames; | ||
@@ -500,3 +489,3 @@ return { | ||
const maps = core.virtualFiles.getMaps(virtualFile); | ||
for (const [source, map] of maps) { | ||
for (const [source, [_, map]] of maps) { | ||
const start = map.toSourceOffset(declaration.getStart()); | ||
@@ -503,0 +492,0 @@ const end = map.toSourceOffset(declaration.getEnd()); |
{ | ||
"name": "vue-component-meta", | ||
"version": "1.7.8", | ||
"version": "1.7.9", | ||
"main": "out/index.js", | ||
@@ -16,6 +16,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/language-core": "1.6.9", | ||
"@vue/language-core": "1.7.8", | ||
"@volar/typescript": "1.7.3", | ||
"@vue/language-core": "1.7.9", | ||
"typesafe-path": "^0.2.2", | ||
"vue-component-type-helpers": "1.7.8" | ||
"vue-component-type-helpers": "1.7.9" | ||
}, | ||
@@ -30,3 +30,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "9841dc5c7b19c2b1d24fcc95a808f29af39710b8" | ||
"gitHead": "70f9ebedbc55a8d342ec425cc483dfe39c4b7489" | ||
} |
38986
796
+ Added@volar/typescript@1.7.3
+ Added@volar/language-core@1.7.3(transitive)
+ Added@volar/source-map@1.7.3(transitive)
+ Added@volar/typescript@1.7.3(transitive)
+ Added@vue/language-core@1.7.9(transitive)
+ Addedvue-component-type-helpers@1.7.9(transitive)
- Removed@volar/language-core@1.6.9
- Removed@volar/language-core@1.6.9(transitive)
- Removed@volar/source-map@1.6.9(transitive)
- Removed@vue/language-core@1.7.8(transitive)
- Removedvue-component-type-helpers@1.7.8(transitive)
Updated@vue/language-core@1.7.9