vue-component-meta
Advanced tools
Comparing version 0.40.1 to 0.40.2
@@ -0,4 +1,15 @@ | ||
import * as vue from '@volar/vue-language-core'; | ||
import * as ts from 'typescript/lib/tsserverlibrary'; | ||
import type { MetaCheckerOptions, ComponentMeta, EventMeta, ExposeMeta, MetaCheckerSchemaOptions, PropertyMeta, PropertyMetaSchema, SlotMeta } from './types'; | ||
export type { MetaCheckerOptions, ComponentMeta, EventMeta, ExposeMeta, MetaCheckerSchemaOptions, PropertyMeta, PropertyMetaSchema, SlotMeta }; | ||
export declare type ComponentMetaChecker = ReturnType<typeof createComponentMetaCheckerBase>; | ||
export declare function createComponentMetaCheckerByJsonConfig(root: string, json: any, checkerOptions?: MetaCheckerOptions): { | ||
getExportNames: (componentPath: string) => string[]; | ||
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta; | ||
__internal__: { | ||
program: ts.Program; | ||
tsLs: ts.LanguageService; | ||
typeChecker: ts.TypeChecker; | ||
}; | ||
}; | ||
export declare function createComponentMetaChecker(tsconfigPath: string, checkerOptions?: MetaCheckerOptions): { | ||
@@ -13,1 +24,10 @@ getExportNames: (componentPath: string) => string[]; | ||
}; | ||
declare function createComponentMetaCheckerBase(tsconfigPath: string, parsedCommandLine: vue.ParsedCommandLine, checkerOptions: MetaCheckerOptions): { | ||
getExportNames: (componentPath: string) => string[]; | ||
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta; | ||
__internal__: { | ||
program: ts.Program; | ||
tsLs: ts.LanguageService; | ||
typeChecker: ts.TypeChecker; | ||
}; | ||
}; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createComponentMetaChecker = void 0; | ||
exports.createComponentMetaChecker = exports.createComponentMetaCheckerByJsonConfig = void 0; | ||
const vue = require("@volar/vue-language-core"); | ||
const vue_language_core_1 = require("@volar/vue-language-core"); | ||
const ts = require("typescript/lib/tsserverlibrary"); | ||
const parseConfigHost = { | ||
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames, | ||
readDirectory: (path, extensions, exclude, include, depth) => { | ||
return ts.sys.readDirectory(path, [...extensions, '.vue'], exclude, include, depth); | ||
}, | ||
fileExists: ts.sys.fileExists, | ||
readFile: ts.sys.readFile, | ||
}; | ||
function createComponentMetaCheckerByJsonConfig(root, json, checkerOptions = {}) { | ||
const parsedCommandLine = vue.createParsedCommandLineByJson(ts, parseConfigHost, root, json); | ||
for (const error of parsedCommandLine.errors) { | ||
console.error(error); | ||
} | ||
return createComponentMetaCheckerBase(root + '/jsconfig.json', parsedCommandLine, checkerOptions); | ||
} | ||
exports.createComponentMetaCheckerByJsonConfig = createComponentMetaCheckerByJsonConfig; | ||
function createComponentMetaChecker(tsconfigPath, checkerOptions = {}) { | ||
const parsedCommandLine = vue.createParsedCommandLine(ts, { | ||
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames, | ||
readDirectory: (path, extensions, exclude, include, depth) => { | ||
return ts.sys.readDirectory(path, [...extensions, '.vue'], exclude, include, depth); | ||
}, | ||
fileExists: ts.sys.fileExists, | ||
readFile: ts.sys.readFile, | ||
}, tsconfigPath); | ||
const parsedCommandLine = vue.createParsedCommandLine(ts, parseConfigHost, tsconfigPath); | ||
for (const error of parsedCommandLine.errors) { | ||
console.error(error); | ||
} | ||
return createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checkerOptions); | ||
} | ||
exports.createComponentMetaChecker = createComponentMetaChecker; | ||
function createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checkerOptions) { | ||
const scriptSnapshot = {}; | ||
@@ -27,3 +43,3 @@ const globalComponentName = tsconfigPath.replace(/\\/g, '/') + '.global.ts'; | ||
let fileText; | ||
if (fileName.endsWith('.meta.ts')) { | ||
if (isMetaFileName(fileName)) { | ||
fileText = getMetaScriptContent(fileName); | ||
@@ -80,2 +96,5 @@ } | ||
}; | ||
function isMetaFileName(fileName) { | ||
return fileName.endsWith('.meta.ts'); | ||
} | ||
function getMetaFileName(fileName) { | ||
@@ -130,3 +149,3 @@ return (fileName.endsWith('.vue') ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + '.meta.ts'; | ||
const vueDefaults = componentPath.endsWith('.vue') && exportName === 'default' | ||
? readVueComponentDefaultProps(core, snapshot.getText(0, snapshot.getLength()), printer) | ||
? readVueComponentDefaultProps(core, snapshot, printer) | ||
: {}; | ||
@@ -217,3 +236,2 @@ const tsDefaults = !componentPath.endsWith('.vue') ? readTsComponentDefaultProps(componentPath.substring(componentPath.lastIndexOf('.') + 1), // ts | js | tsx | jsx | ||
} | ||
exports.createComponentMetaChecker = createComponentMetaChecker; | ||
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options }) { | ||
@@ -353,3 +371,3 @@ var _a; | ||
} | ||
function readVueComponentDefaultProps(core, vueFileText, printer) { | ||
function readVueComponentDefaultProps(core, vueFileScript, printer) { | ||
let result = {}; | ||
@@ -361,3 +379,3 @@ scriptSetupWorker(); | ||
var _a; | ||
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileText, {}, ts, core.plugins); | ||
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileScript, {}, ts, core.plugins); | ||
const descriptor = vueSourceFile.sfc; | ||
@@ -404,3 +422,3 @@ const scriptSetupRanges = descriptor.scriptSetupAst ? (0, vue_language_core_1.parseScriptSetupRanges)(ts, descriptor.scriptSetupAst) : undefined; | ||
function scriptWorker() { | ||
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileText, {}, ts, core.plugins); | ||
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileScript, {}, ts, core.plugins); | ||
const descriptor = vueSourceFile.sfc; | ||
@@ -407,0 +425,0 @@ if (descriptor.script) { |
{ | ||
"name": "vue-component-meta", | ||
"version": "0.40.1", | ||
"version": "0.40.2", | ||
"main": "out/index.js", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/vue-language-core": "0.40.1" | ||
"@volar/vue-language-core": "0.40.2" | ||
}, | ||
@@ -22,3 +22,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "4f92ef83a905c6d46cc92653ad87e0aec10f4e53" | ||
"gitHead": "baa87a77b8cb56cf31dab158e5f76af42fe65b39" | ||
} |
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
28954
625
+ Added@volar/code-gen@0.40.2(transitive)
+ Added@volar/source-map@0.40.2(transitive)
+ Added@volar/vue-language-core@0.40.2(transitive)
+ Added@vue/reactivity@3.2.37(transitive)
+ Added@vue/shared@3.2.37(transitive)
- Removed@volar/code-gen@0.40.1(transitive)
- Removed@volar/source-map@0.40.1(transitive)
- Removed@volar/vue-language-core@0.40.1(transitive)