UNPKG

2.19 kBTypeScriptView Raw
1import { Options } from 'prettier';
2import { OptimizeOptions } from 'svgo';
3import { Options as Options$1 } from '@svgr/babel-preset';
4import { TransformOptions } from '@babel/core';
5
6interface State {
7 filePath?: string;
8 componentName: string;
9 caller?: {
10 name?: string;
11 previousExport?: string | null;
12 defaultPlugins?: ConfigPlugin[];
13 };
14}
15
16interface Plugin {
17 (code: string, config: Config, state: State): string;
18}
19declare type ConfigPlugin = string | Plugin;
20
21interface Config {
22 ref?: boolean;
23 titleProp?: boolean;
24 descProp?: boolean;
25 expandProps?: boolean | 'start' | 'end';
26 dimensions?: boolean;
27 icon?: boolean | string | number;
28 native?: boolean;
29 svgProps?: {
30 [key: string]: string;
31 };
32 replaceAttrValues?: {
33 [key: string]: string;
34 };
35 runtimeConfig?: boolean;
36 typescript?: boolean;
37 prettier?: boolean;
38 prettierConfig?: Options;
39 svgo?: boolean;
40 svgoConfig?: OptimizeOptions;
41 configFile?: string;
42 template?: Options$1['template'];
43 memo?: boolean;
44 exportType?: 'named' | 'default';
45 namedExport?: string;
46 jsxRuntime?: 'classic' | 'classic-preact' | 'automatic';
47 index?: boolean;
48 plugins?: ConfigPlugin[];
49 jsx?: {
50 babelConfig?: TransformOptions;
51 };
52}
53declare const DEFAULT_CONFIG: Config;
54declare const resolveConfig: {
55 (searchFrom?: string, configFile?: string): Promise<Config | null>;
56 sync(searchFrom?: string, configFile?: string): Config | null;
57};
58declare const resolveConfigFile: {
59 (filePath: string): Promise<string | null>;
60 sync(filePath: string): string | null;
61};
62declare const loadConfig: {
63 ({ configFile, ...baseConfig }: Config, state?: Pick<State, 'filePath'>): Promise<Config>;
64 sync({ configFile, ...baseConfig }: Config, state?: Pick<State, 'filePath'>): Config;
65};
66
67declare const transform: {
68 (code: string, config?: Config, state?: Partial<State>): Promise<string>;
69 sync(code: string, config?: Config, state?: Partial<State>): string;
70};
71
72export { Config, ConfigPlugin, DEFAULT_CONFIG, Plugin, State, loadConfig, resolveConfig, resolveConfigFile, transform };