vue-component-meta
Advanced tools
Comparing version 2.0.19 to 2.0.20
@@ -9,3 +9,3 @@ import * as ts from 'typescript'; | ||
/** | ||
* @deprecated Use `createCheckerByJson` instead. | ||
* @deprecated Use `createChecker` instead. | ||
*/ | ||
@@ -12,0 +12,0 @@ export declare const createComponentMetaChecker: typeof createChecker; |
@@ -26,3 +26,3 @@ "use strict"; | ||
/** | ||
* @deprecated Use `createCheckerByJson` instead. | ||
* @deprecated Use `createChecker` instead. | ||
*/ | ||
@@ -29,0 +29,0 @@ exports.createComponentMetaChecker = createChecker; |
import * as vue from '@vue/language-core'; | ||
import type * as ts from 'typescript'; | ||
import { TypeScriptProjectHost } from '@volar/typescript'; | ||
import type { MetaCheckerOptions, ComponentMeta } from './types'; | ||
@@ -27,3 +28,3 @@ export * from './types'; | ||
}; | ||
export declare function baseCreate(ts: typeof import('typescript'), host: vue.TypeScriptProjectHost, vueCompilerOptions: vue.VueCompilerOptions, checkerOptions: MetaCheckerOptions, globalComponentName: string): { | ||
export declare function baseCreate(ts: typeof import('typescript'), configFileName: string | undefined, projectHost: TypeScriptProjectHost, vueCompilerOptions: vue.VueCompilerOptions, checkerOptions: MetaCheckerOptions, globalComponentName: string): { | ||
getExportNames: (componentPath: string) => string[]; | ||
@@ -30,0 +31,0 @@ getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta; |
@@ -44,4 +44,2 @@ "use strict"; | ||
const projectHost = { | ||
...ts.sys, | ||
configFileName, | ||
getCurrentDirectory: () => rootPath, | ||
@@ -61,7 +59,5 @@ getProjectVersion: () => projectVersion.toString(), | ||
}, | ||
scriptIdToFileName: id => id, | ||
fileNameToScriptId: id => id, | ||
}; | ||
return { | ||
...baseCreate(ts, projectHost, parsedCommandLine.vueOptions, checkerOptions, globalComponentName), | ||
...baseCreate(ts, configFileName, projectHost, parsedCommandLine.vueOptions, checkerOptions, globalComponentName), | ||
updateFile(fileName, text) { | ||
@@ -88,8 +84,8 @@ fileName = fileName.replace(windowsPathReg, '/'); | ||
} | ||
function baseCreate(ts, host, vueCompilerOptions, checkerOptions, globalComponentName) { | ||
function baseCreate(ts, configFileName, projectHost, vueCompilerOptions, checkerOptions, globalComponentName) { | ||
const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>'); | ||
const metaSnapshots = {}; | ||
const getScriptFileNames = host.getScriptFileNames; | ||
const getScriptSnapshot = host.getScriptSnapshot; | ||
host.getScriptFileNames = () => { | ||
const getScriptFileNames = projectHost.getScriptFileNames; | ||
const getScriptSnapshot = projectHost.getScriptSnapshot; | ||
projectHost.getScriptFileNames = () => { | ||
const names = getScriptFileNames(); | ||
@@ -103,3 +99,3 @@ return [ | ||
}; | ||
host.getScriptSnapshot = fileName => { | ||
projectHost.getScriptSnapshot = fileName => { | ||
if (isMetaFileName(fileName)) { | ||
@@ -118,4 +114,32 @@ if (!metaSnapshots[fileName]) { | ||
}; | ||
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, ts.sys.useCaseSensitiveFileNames, () => host.getProjectVersion?.() ?? '', () => host.getScriptFileNames(), host.getCompilationSettings(), vueCompilerOptions); | ||
const language = (0, typescript_1.createTypeScriptLanguage)(ts, [vueLanguagePlugin], host); | ||
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, () => projectHost.getProjectVersion?.() ?? '', fileName => { | ||
const fileMap = new vue.FileMap(ts.sys.useCaseSensitiveFileNames); | ||
for (const vueFileName of projectHost.getScriptFileNames()) { | ||
fileMap.set(vueFileName, undefined); | ||
} | ||
return fileMap.has(fileName); | ||
}, projectHost.getCompilationSettings(), vueCompilerOptions); | ||
const language = vue.createLanguage([ | ||
vueLanguagePlugin, | ||
{ | ||
getLanguageId(fileName) { | ||
return (0, typescript_1.resolveFileLanguageId)(fileName); | ||
}, | ||
}, | ||
], new vue.FileMap(ts.sys.useCaseSensitiveFileNames), fileName => { | ||
const snapshot = projectHost.getScriptSnapshot(fileName); | ||
if (snapshot) { | ||
language.scripts.set(fileName, snapshot); | ||
} | ||
else { | ||
language.scripts.delete(fileName); | ||
} | ||
}); | ||
language.typescript = { | ||
sys: ts.sys, | ||
configFileName, | ||
asFileName: s => s, | ||
asScriptId: s => s, | ||
...(0, typescript_1.createLanguageServiceHost)(ts, ts.sys, language, s => s, projectHost), | ||
}; | ||
const { languageServiceHost } = language.typescript; | ||
@@ -239,3 +263,3 @@ const tsLs = ts.createLanguageService(languageServiceHost); | ||
const printer = ts.createPrinter(checkerOptions.printer); | ||
const snapshot = host.getScriptSnapshot(componentPath); | ||
const snapshot = projectHost.getScriptSnapshot(componentPath); | ||
const vueFile = language.scripts.get(componentPath)?.generated?.root; | ||
@@ -512,12 +536,11 @@ const vueDefaults = vueFile && exportName === 'default' | ||
if (script) { | ||
for (const [source, [_, map]] of language.maps.forEach(script.code)) { | ||
const start = map.getSourceOffset(declaration.getStart()); | ||
const end = map.getSourceOffset(declaration.getEnd()); | ||
if (start && end) { | ||
return { | ||
file: source, | ||
range: [start[0], end[0]], | ||
}; | ||
for (const [source, _, map] of language.maps.forEach(script.code)) { | ||
for (const [start] of map.getSourceOffsets(declaration.getStart())) { | ||
for (const [end] of map.getSourceOffsets(declaration.getEnd())) { | ||
return { | ||
file: source, | ||
range: [start, end], | ||
}; | ||
} | ||
} | ||
; | ||
} | ||
@@ -524,0 +547,0 @@ } |
import type * as ts from 'typescript'; | ||
export type ComponentMetaChecker = ReturnType<typeof import('./base')['baseCreate']>; | ||
export type ComponentMetaChecker = ReturnType<typeof import('./base')['createCheckerBase']>; | ||
export interface Declaration { | ||
@@ -4,0 +4,0 @@ file: string; |
{ | ||
"name": "vue-component-meta", | ||
"version": "2.0.19", | ||
"version": "2.0.20", | ||
"license": "MIT", | ||
@@ -15,6 +15,6 @@ "files": [ | ||
"dependencies": { | ||
"@volar/typescript": "~2.2.4", | ||
"@vue/language-core": "2.0.19", | ||
"@volar/typescript": "~2.3.0-alpha.14", | ||
"@vue/language-core": "2.0.20", | ||
"path-browserify": "^1.0.1", | ||
"vue-component-type-helpers": "2.0.19" | ||
"vue-component-type-helpers": "2.0.20" | ||
}, | ||
@@ -33,3 +33,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "a9fae154ad1efc4359866cfd10251d53e4b0faed" | ||
"gitHead": "e1a5d2f136bf60a772c9655f9f5474c7f71a2ff9" | ||
} |
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
43902
913
+ Added@volar/language-core@2.3.4(transitive)
+ Added@volar/source-map@2.3.4(transitive)
+ Added@volar/typescript@2.3.4(transitive)
+ Added@vue/language-core@2.0.20(transitive)
+ Addedvscode-uri@3.0.8(transitive)
+ Addedvue-component-type-helpers@2.0.20(transitive)
- Removed@volar/language-core@2.2.5(transitive)
- Removed@volar/source-map@2.2.5(transitive)
- Removed@volar/typescript@2.2.5(transitive)
- Removed@vue/language-core@2.0.19(transitive)
- Removedmuggle-string@0.4.1(transitive)
- Removedvue-component-type-helpers@2.0.19(transitive)
Updated@vue/language-core@2.0.20