index.d.ts 2.1 KB

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