/// import * as MOZ_SourceMap from "source-map"; declare namespace UglifyJS { interface Tokenizer { /** * The type of this token. * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". * "comment1" and "comment2" are for single-line, respectively multi-line comments. */ type: string; /** * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. */ file: string; /** * The "value" of the token. * That's additional information and depends on the token type: "num", "string" and "regexp" tokens you get their literal value. * - For "operator" you get the operator. * - For "punc" it's the punctuation sign (parens, comma, semicolon etc). * - For "atom", "name" and "keyword" it's the name of the identifier * - For comments it's the body of the comment (excluding the initial "//" and "/*". */ value: string; /** * The line number of this token in the original code. * 1-based index. */ line: number; /** * The column number of this token in the original code. * 0-based index. */ col: number; /** * Short for "newline before", it's a boolean that tells us whether there was a newline before this node in the original source. It helps for automatic semicolon insertion. * For multi-line comments in particular this will be set to true if there either was a newline before this comment, or * * if this comment contains a newline. */ nlb: boolean; /** * This doesn't apply for comment tokens, but for all other token types it will be an array of comment tokens that were found before. */ comments_before: string[]; } interface AST_Node { // The first token of this node start: AST_Node; // The last token of this node end: AST_Node; transform(tt: TreeTransformer): AST_Toplevel; } interface AST_Toplevel extends AST_Node { // UglifyJS contains a scope analyzer which figures out variable/function definitions, references etc. // You need to call it manually before compression or mangling. // The figure_out_scope method is defined only on the AST_Toplevel node. figure_out_scope(): void; // Get names that are optimized for GZip compression (names will be generated using the most frequent characters first) compute_char_frequency(): void; mangle_names(): void; print(stream: OutputStream): void; print_to_string(options?: BeautifierOptions): string; } interface MinifyOptions { spidermonkey?: boolean | undefined; outSourceMap?: string | undefined; sourceRoot?: string | undefined; inSourceMap?: string | undefined; fromString?: boolean | undefined; warnings?: boolean | undefined; mangle?: Object | undefined; output?: MinifyOutput | undefined; compress?: Object | undefined; } interface MinifyOutput { code: string; map: string; } function minify(files: string | Array, options?: MinifyOptions): MinifyOutput; interface ParseOptions { // Default is false strict?: boolean | undefined; // Input file name, default is null filename?: string | undefined; // Default is null toplevel?: AST_Toplevel | undefined; } /** * The parser creates a custom abstract syntax tree given a piece of JavaScript code. * Perhaps you should read about the AST first. */ function parse(code: string, options?: ParseOptions): AST_Toplevel; interface BeautifierOptions { /** * Start indentation on every line (only when `beautify`) */ indent_start?: number | undefined; /** * Indentation level (only when `beautify`) */ indent_level?: number | undefined; /** * Quote all keys in object literals? */ quote_keys?: boolean | undefined; /** * Add a space after colon signs? */ space_colon?: boolean | undefined; /** * Output ASCII-safe? (encodes Unicode characters as ASCII) */ ascii_only?: boolean | undefined; /** * Escape " boolean; /** * UglifyJS provides a TreeWalker object and every node has a walk method that given a walker will apply your visitor to each node in the tree. * Your visitor can return a non-falsy value in order to prevent descending the current node. */ function TreeWalker(visitor: visitor): TreeWalker; // TODO interface TreeTransformer extends TreeWalker { } /** * The tree transformer is a special case of a tree walker. * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. */ function TreeTransformer(before: visitor, after: visitor): TreeTransformer; } export = UglifyJS;