UNPKG

@mpxjs/vuese-parser

Version:

Vue file parser for automatic document generation

285 lines (273 loc) 10.5 kB
// Generated by dts-bundle v0.7.3 // Dependencies for this module: // ../../../../../../typedoc // ../../../../../../@babel/types // ../../../../../../@mpxjs/vuese-parser // ../../../../../../@babel/traverse declare module '@mpxjs/vuese-parser' { import { CommentResult } from '@mpxjs/vuese-parser/jscomments'; import { mergeMixinsOptions } from '@mpxjs/vuese-parser/processMixins'; import Typedoc from 'typedoc'; export * from '@mpxjs/vuese-parser/sfcToAST'; export * from '@mpxjs/vuese-parser/parseJavascript'; export * from '@mpxjs/vuese-parser/parseTemplate'; export * from '@mpxjs/vuese-parser/helper'; export * from '@mpxjs/vuese-parser/jscomments'; export * from '@mpxjs/vuese-parser/getExportFileConfig'; export * from '@mpxjs/vuese-parser/processTsType'; export { mergeMixinsOptions }; export type PropType = string | string[] | null; /** * Since version 7.3.3, `type ParserPlugin` has been added with the `ParserPluginWithOptions` type, * which is a breaking change for vuese, so we will force the installation of the version below 7.3.3, * and the overall upgrade will follow. * https://github.com/babel/babel/blob/master/packages/babel-parser/typings/babel-parser.d.ts#L118 */ type ParserPlugin = 'estree' | 'jsx' | 'flow' | 'flowComments' | 'typescript' | 'doExpressions' | 'objectRestSpread' | 'decorators' | 'decorators-legacy' | 'classProperties' | 'classPrivateProperties' | 'classPrivateMethods' | 'exportDefaultFrom' | 'exportNamespaceFrom' | 'asyncGenerators' | 'functionBind' | 'functionSent' | 'dynamicImport' | 'numericSeparator' | 'optionalChaining' | 'importMeta' | 'bigInt' | 'optionalCatchBinding' | 'throwExpressions' | 'pipelineOperator' | 'nullishCoalescingOperator'; export type BabelParserPlugins = { [key in ParserPlugin]?: boolean; }; export interface EventNameMap { [key: string]: string; } interface CommonResult { name: string; level?: number; describe?: string[] | CommentResult; version?: string[]; } export interface PropsResult extends CommonResult { type: PropType; typeDesc?: string[]; required?: boolean; default?: string; defaultDesc?: string[]; validator?: string; validatorDesc?: string[]; tsInfo?: TsTypeResult[]; } export interface TsTypeResult { name: string; type: string; } export interface EventResult extends CommonResult { isSync: boolean; syncProp: string; argumentsDesc?: string[]; arr?: EventResult[]; } export interface MethodResult extends CommonResult { argumentsDesc?: string[]; returnDesc?: string[]; } export interface ComputedResult { name: string; type?: string[]; describe?: string[]; isFromStore: boolean; } export interface MixInResult { mixIn: string; } export interface DataResult { name: string; type: string; describe?: string[]; default?: string; } export interface WatchResult { name: string; describe?: string[]; argumentsDesc?: string[]; } export type AttrsMap = Record<string, string>; export interface SlotResult { name: string; describe: string; backerDesc: string; bindings: AttrsMap; scoped: boolean; target: 'template' | 'script'; version?: string[]; } export interface ExternalClassesResult { name: string; describe: string[]; } export interface ParserOptions { isMpx?: boolean; isMixin?: boolean; filepath?: string; jsFilePath?: string; fnMixins?: Record<string, { mixins: string[]; vueseRes: ParserResult; }>; typedocProject?: Typedoc.Models.ProjectReflection; onProp?: { (propsRes: PropsResult): void; }; onTsType?: { (tsTypeRes: TsTypeResult[]): void; }; onEvent?: { (eventRes: EventResult): void; }; onMethod?: { (methodRes: MethodResult): void; }; onComputed?: { (computedRes: ComputedResult): void; }; onMixIn?: { (mixInRes: MixInResult): void; }; onData?: { (dataRes: DataResult): void; }; onSlot?: { (slotRes: SlotResult): void; }; onName?: { (name: string): void; }; onDesc?: { (desc: CommentResult): void; }; onWatch?: { (watch: WatchResult): void; }; onExternalClasses?: { (externalClasses: ExternalClassesResult): void; }; babelParserPlugins?: BabelParserPlugins; basedir?: string; includeSyncEvent?: boolean; } export interface ParserResult { props?: PropsResult[]; tsType?: TsTypeResult[]; events?: EventResult[]; slots?: SlotResult[]; mixIns?: MixInResult[]; methods?: MethodResult[]; computed?: ComputedResult[]; data?: DataResult[]; watch?: WatchResult[]; name?: string; componentDesc?: CommentResult; externalClasses?: ExternalClassesResult[]; } export function parser(source: string, options?: ParserOptions): ParserResult; } declare module '@mpxjs/vuese-parser/jscomments' { import * as bt from '@babel/types'; export interface CommentResult { default: string[]; [key: string]: string[]; } /** * @param cnode {bt.Node} a node with comments * @param trailing {boolean} Whether to process the tailing comment */ export function getComments(cnode: bt.Node, trailing?: boolean): CommentResult; /** * Extract the leading comments of the default export statement * 1、If the default export is a class with a decorator, * we should find the trailing comments of the last decorator node. * 2、In other cases, directly use the leading commets of the default export statement. */ export function getComponentDescribe(node: bt.ExportDefaultDeclaration): CommentResult; export function isCommentLine(node: { type: string; }): boolean; export function isCommentBlock(node: { type: string; }): boolean; export function isCodeBlockDeclaration(value: string): boolean; export function filterBlockComments(comments: string[]): string[]; } declare module '@mpxjs/vuese-parser/processMixins' { import * as bt from '@babel/types'; import { ParserResult } from '@mpxjs/vuese-parser/index'; export function findImportDeclaration(filePath: string, name: string): { ast: bt.File; filePath: string; }; export function mergeMixinsOptions(parserRes: ParserResult): void; } declare module '@mpxjs/vuese-parser/sfcToAST' { import { BabelParserPlugins } from '@mpxjs/vuese-parser'; import * as bt from '@babel/types'; type pluginKeys = keyof BabelParserPlugins; export interface AstResult { sourceType?: string; jsAst?: bt.File; templateAst?: object; styleSource?: string; jsSource: string; jsFilePath: string; templateSource: string; } export function sfcToAST(source: string, babelParserPlugins?: BabelParserPlugins, basedir?: string): AstResult; export function getBabelParserPlugins(plugins?: BabelParserPlugins): pluginKeys[]; export {}; } declare module '@mpxjs/vuese-parser/parseJavascript' { import { NodePath } from '@babel/traverse'; import * as bt from '@babel/types'; import { ParserOptions, EventNameMap } from '@mpxjs/vuese-parser'; import { Seen } from '@mpxjs/vuese-parser/seen'; export function setOptionsLevel(num: number): void; export function parseJavascript(ast: bt.File, seenEvent: Seen, options: ParserOptions, source?: string): string; export function processEmitCallExpression(path: NodePath<bt.CallExpression>, seenEvent: Seen, options: ParserOptions, parentExpressionStatementNodePath: NodePath<bt.Node>, eventNameMap?: EventNameMap): void; } declare module '@mpxjs/vuese-parser/parseTemplate' { import { ParserOptions } from '@mpxjs/vuese-parser'; import { Seen } from '@mpxjs/vuese-parser/seen'; export function parseTemplate(templateAst: any, seenEvent: Seen, options: ParserOptions): void; } declare module '@mpxjs/vuese-parser/helper' { import { NodePath } from '@babel/traverse'; import * as bt from '@babel/types'; /** * If a node satisfies the following conditions, then we will use this node as a Vue component. * 1. It is a default export * 2. others... */ export function isVueComponent(path: NodePath, componentLevel: number): boolean; export function isVueOption(path: NodePath<bt.ObjectProperty> | NodePath<bt.ObjectMethod>, optionsName: string, componentLevel: number): boolean; export function runFunction(fnCode: bt.Node): any; export function getValueFromGenerate(node: any): any; export function computesFromStore(node: any): boolean; export function getLiteralValue(node: bt.Node): string; export function normalizePath(filePath: any): string; } declare module '@mpxjs/vuese-parser/getExportFileConfig' { type Mixins = { name: string; path: string; }[]; export function getExportFileConfig(mixinEntry: string): Mixins; export {}; } declare module '@mpxjs/vuese-parser/processTsType' { import * as bt from '@babel/types'; import { ParserOptions } from '@mpxjs/vuese-parser/index'; import Typedoc from 'typedoc'; type ProcessTsTypeReturnItem = { isOriginType: boolean; originName: string; typeRes: string; }; export function processTsType(node: bt.TSAsExpression, options: ParserOptions, originSource: string): ProcessTsTypeReturnItem[] | undefined; export function setTypedocProject(project?: Typedoc.Models.ProjectReflection): void; export function createTypedocProject(config: any): Promise<Typedoc.Models.ProjectReflection | undefined>; export {}; } declare module '@mpxjs/vuese-parser/seen' { export class Seen { seenSet: Set<unknown>; seen(label: string): boolean; } }