1 | import { types, ConfigAPI, NodePath } from '@babel/core';
|
2 | import { TemplateBuilder } from '@babel/template';
|
3 |
|
4 | interface TemplateVariables {
|
5 | componentName: string;
|
6 | interfaces: types.TSInterfaceDeclaration[];
|
7 | props: (types.ObjectPattern | types.Identifier)[];
|
8 | imports: types.ImportDeclaration[];
|
9 | exports: (types.VariableDeclaration | types.ExportDeclaration | types.Statement)[];
|
10 | jsx: types.JSXElement;
|
11 | }
|
12 | interface TemplateContext {
|
13 | options: Options;
|
14 | tpl: TemplateBuilder<types.Statement | types.Statement[]>['ast'];
|
15 | }
|
16 | interface Template {
|
17 | (variables: TemplateVariables, context: TemplateContext): types.Statement | types.Statement[];
|
18 | }
|
19 | interface State {
|
20 | componentName: string;
|
21 | caller?: {
|
22 | previousExport?: string | null;
|
23 | };
|
24 | }
|
25 | interface JSXRuntimeImport {
|
26 | source: string;
|
27 | namespace?: string;
|
28 | defaultSpecifier?: string;
|
29 | specifiers?: string[];
|
30 | }
|
31 | interface Options {
|
32 | typescript?: boolean;
|
33 | titleProp?: boolean;
|
34 | descProp?: boolean;
|
35 | expandProps?: boolean | 'start' | 'end';
|
36 | ref?: boolean;
|
37 | template?: Template;
|
38 | state: State;
|
39 | native?: boolean;
|
40 | memo?: boolean;
|
41 | exportType?: 'named' | 'default';
|
42 | namedExport?: string;
|
43 | jsxRuntime?: 'automatic' | 'classic';
|
44 | jsxRuntimeImport?: JSXRuntimeImport;
|
45 | importSource?: string;
|
46 | }
|
47 |
|
48 | declare const plugin: (_: ConfigAPI, opts: Options) => {
|
49 | visitor: {
|
50 | Program(path: NodePath<types.Program>): void;
|
51 | };
|
52 | };
|
53 |
|
54 | export { Options, Template, plugin as default };
|