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 | export namespace Terser {
|
38 | export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
39 |
|
40 | export interface ParseOptions {
|
41 | bare_returns?: boolean
|
42 |
|
43 | ecma?: ECMA
|
44 | html5_comments?: boolean
|
45 | shebang?: boolean
|
46 | }
|
47 |
|
48 | export interface CompressOptions {
|
49 | arguments?: boolean
|
50 | arrows?: boolean
|
51 | booleans_as_integers?: boolean
|
52 | booleans?: boolean
|
53 | collapse_vars?: boolean
|
54 | comparisons?: boolean
|
55 | computed_props?: boolean
|
56 | conditionals?: boolean
|
57 | dead_code?: boolean
|
58 | defaults?: boolean
|
59 | directives?: boolean
|
60 | drop_console?: boolean
|
61 | drop_debugger?: boolean
|
62 | ecma?: ECMA
|
63 | evaluate?: boolean
|
64 | expression?: boolean
|
65 | global_defs?: object
|
66 | hoist_funs?: boolean
|
67 | hoist_props?: boolean
|
68 | hoist_vars?: boolean
|
69 | ie8?: boolean
|
70 | if_return?: boolean
|
71 | inline?: boolean | InlineFunctions
|
72 | join_vars?: boolean
|
73 | keep_classnames?: boolean | RegExp
|
74 | keep_fargs?: boolean
|
75 | keep_fnames?: boolean | RegExp
|
76 | keep_infinity?: boolean
|
77 | loops?: boolean
|
78 | module?: boolean
|
79 | negate_iife?: boolean
|
80 | passes?: number
|
81 | properties?: boolean
|
82 | pure_funcs?: string[]
|
83 | pure_getters?: boolean | 'strict'
|
84 | reduce_funcs?: boolean
|
85 | reduce_vars?: boolean
|
86 | sequences?: boolean | number
|
87 | side_effects?: boolean
|
88 | switches?: boolean
|
89 | toplevel?: boolean
|
90 | top_retain?: null | string | string[] | RegExp
|
91 | typeofs?: boolean
|
92 | unsafe_arrows?: boolean
|
93 | unsafe?: boolean
|
94 | unsafe_comps?: boolean
|
95 | unsafe_Function?: boolean
|
96 | unsafe_math?: boolean
|
97 | unsafe_symbols?: boolean
|
98 | unsafe_methods?: boolean
|
99 | unsafe_proto?: boolean
|
100 | unsafe_regexp?: boolean
|
101 | unsafe_undefined?: boolean
|
102 | unused?: boolean
|
103 | }
|
104 |
|
105 | export enum InlineFunctions {
|
106 | Disabled = 0,
|
107 | SimpleFunctions = 1,
|
108 | WithArguments = 2,
|
109 | WithArgumentsAndVariables = 3
|
110 | }
|
111 |
|
112 | export interface MangleOptions {
|
113 | eval?: boolean
|
114 | keep_classnames?: boolean | RegExp
|
115 | keep_fnames?: boolean | RegExp
|
116 | module?: boolean
|
117 | nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
118 | properties?: boolean | ManglePropertiesOptions
|
119 | reserved?: string[]
|
120 | safari10?: boolean
|
121 | toplevel?: boolean
|
122 | }
|
123 |
|
124 | /**
|
125 | * An identifier mangler for which the output is invariant with respect to the source code.
|
126 | */
|
127 | export interface SimpleIdentifierMangler {
|
128 | |
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | get(n: number): string
|
135 | }
|
136 |
|
137 | |
138 |
|
139 |
|
140 | export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | consider(chars: string, delta: number): number
|
148 | |
149 |
|
150 |
|
151 | reset(): void
|
152 | |
153 |
|
154 |
|
155 | sort(): void
|
156 | }
|
157 |
|
158 | export interface ManglePropertiesOptions {
|
159 | builtins?: boolean
|
160 | debug?: boolean
|
161 | keep_quoted?: boolean | 'strict'
|
162 | nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
163 | regex?: RegExp | string
|
164 | reserved?: string[]
|
165 | }
|
166 |
|
167 | export interface FormatOptions {
|
168 | ascii_only?: boolean
|
169 |
|
170 | beautify?: boolean
|
171 | braces?: boolean
|
172 | comments?:
|
173 | | boolean
|
174 | | 'all'
|
175 | | 'some'
|
176 | | RegExp
|
177 | | ((
|
178 | node: any,
|
179 | comment: {
|
180 | value: string
|
181 | type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
182 | pos: number
|
183 | line: number
|
184 | col: number
|
185 | }
|
186 | ) => boolean)
|
187 | ecma?: ECMA
|
188 | ie8?: boolean
|
189 | keep_numbers?: boolean
|
190 | indent_level?: number
|
191 | indent_start?: number
|
192 | inline_script?: boolean
|
193 | keep_quoted_props?: boolean
|
194 | max_line_len?: number | false
|
195 | preamble?: string
|
196 | preserve_annotations?: boolean
|
197 | quote_keys?: boolean
|
198 | quote_style?: OutputQuoteStyle
|
199 | safari10?: boolean
|
200 | semicolons?: boolean
|
201 | shebang?: boolean
|
202 | shorthand?: boolean
|
203 | source_map?: SourceMapOptions
|
204 | webkit?: boolean
|
205 | width?: number
|
206 | wrap_iife?: boolean
|
207 | wrap_func_args?: boolean
|
208 | }
|
209 |
|
210 | export enum OutputQuoteStyle {
|
211 | PreferDouble = 0,
|
212 | AlwaysSingle = 1,
|
213 | AlwaysDouble = 2,
|
214 | AlwaysOriginal = 3
|
215 | }
|
216 |
|
217 | export interface MinifyOptions {
|
218 | compress?: boolean | CompressOptions
|
219 | ecma?: ECMA
|
220 | enclose?: boolean | string
|
221 | ie8?: boolean
|
222 | keep_classnames?: boolean | RegExp
|
223 | keep_fnames?: boolean | RegExp
|
224 | mangle?: boolean | MangleOptions
|
225 | module?: boolean
|
226 | nameCache?: object
|
227 | format?: FormatOptions
|
228 | /** @deprecated deprecated */
|
229 | output?: FormatOptions
|
230 | parse?: ParseOptions
|
231 | safari10?: boolean
|
232 | sourceMap?: boolean | SourceMapOptions
|
233 | toplevel?: boolean
|
234 | }
|
235 |
|
236 | export interface MinifyOutput {
|
237 | code?: string
|
238 | map?: object | string
|
239 | decoded_map?: object | null
|
240 | }
|
241 |
|
242 | export interface SourceMapOptions {
|
243 |
|
244 | content?: object | string
|
245 | includeSources?: boolean
|
246 | filename?: string
|
247 | root?: string
|
248 | url?: string | 'inline'
|
249 | }
|
250 | }
|