-
Notifications
You must be signed in to change notification settings - Fork 4
/
binding.d.ts
101 lines (99 loc) · 3.68 KB
/
binding.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface Caller {
name?: string
previousExport?: string
}
/** The state linked to the transformation. */
export interface State {
/** The name of the file that is generated, mainly used to find runtime config file to apply. */
filePath?: string
/** The name of the component that will be used in the generated component. */
componentName?: string
/**
* If you create a tool based on SVGR, it is always better to specify `state.caller`.
* It permits the inter-operability betweens plugins.
* If someone create a SVGR plugin it could adapt it specifically to your tool.
*/
caller?: Caller
}
export interface TransformOutput {
code: string
map?: string
output?: string
}
export interface JsJsxRuntimeImport {
source: string
namespace?: string
defaultSpecifier?: string
specifiers?: Array<string>
}
export interface JsConfig {
/** Setting this to `true` will forward ref to the root SVG tag. */
ref?: boolean
/**
* Add title tag via title property.
* If title_prop is set to true and no title is provided at render time, this will fallback to an existing title element in the svg if exists.
*/
titleProp?: boolean
/**
* Add desc tag via desc property.
* If desc_prop is set to true and no description is provided at render time, this will fallback to an existing desc element in the svg if exists.
*/
descProp?: boolean
/**
* All properties given to component will be forwarded on SVG tag.
* Possible values: "start", "end" or false.
*/
expandProps?: boolean | string
/**
* Keep `width` and `height` attributes from the root SVG tag.
* Removal is guaranteed if `dimensions: false`, unlike the `remove_dimensions: true` SVGO plugin option which also generates a `viewBox` from the dimensions if no `viewBox` is present.
*/
dimensions?: boolean
/**
* Replace SVG `width` and `height` by a custom value.
* If value is omitted, it uses `1em` in order to make SVG size inherits from text size.
*/
icon?: boolean | string | number
/**
* Modify all SVG nodes with uppercase and use a specific template with `react-native-svg` imports.
* All unsupported nodes will be removed.
*/
native?: boolean
/** Add props to the root SVG tag. */
svgProps?: { [key: string]: string }
/** Generates `.tsx` files with TypeScript typings. */
typescript?: boolean
/** Setting this to `true` will wrap the exported component in `React.memo`. */
memo?: boolean
/**
* Replace an attribute value by an other.
* The main usage of this option is to change an icon color to "currentColor" in order to inherit from text color.
*/
replaceAttrValues?: { [key: string]: string }
/**
* Specify a JSX runtime to use.
* * "classic": adds `import * as React from 'react'` on the top of file
* * "automatic": do not add anything
* * "classic-preact": adds `import { h } from 'preact'` on the top of file
*/
jsxRuntime?: string
/** Specify a custom JSX runtime source to use. Allows to customize the import added at the top of generated file. */
jsxRuntimeImport?: JsJsxRuntimeImport
/** The named export defaults to `ReactComponent`, can be customized with the `named_export` option. */
namedExport?: string
/** If you prefer named export in any case, you may set the `export_type` option to `named`. */
exportType?: 'named' | 'default'
}
export interface JsCaller {
name?: string
previousExport?: string
}
export interface JsState {
filePath?: string
componentName?: string
caller?: JsCaller
}
export declare function transform(code: string, config?: JsConfig | undefined | null, state?: JsState | undefined | null): Promise<unknown>