NUglify
Describes how to output the opening curly-brace for blocks when the OutputMode
is set to MultipleLines.
Output the opening curly-brace block-start character on its own new line. Ex:
if (condition)
{
...
}
Output the opening curly-brace block-start character at the end of the previous line. Ex:
if (condition) {
...
}
Output the opening curly-brace block-start character on the same line or a new line
depending on how it was specified in the sources.
Helper class to hold common data elements
Regular expression to identifier replacement token syntax
Common settings shared between CSS and JS settings objects
Gets or sets a boolean value indicating whether embedded asp.net blocks (<% %>) should be recognized and output as is. Default is false.
Gets or sets a value indicating whether the opening curly brace for blocks is
on its own line (NewLine, default) or on the same line as the preceding code (SameLine)
or taking a hint from the source code position (UseSource). Only relevant when OutputMode is
set to MultipleLines.
Gets or sets a flag for whether to ignore ALL errors found in the input code.
Default is false.
Gets or sets an integer value specifying the number of spaces per indent level when in MultipleLines output mode. (Default = 4)
Gets or sets the column position at which the line will be broken at the next available opportunity.
Default value is int.MaxValue - 1000.
Gets or sets a value indicating the output mode:
SingleLine (default) - output all code on a single line;
MultipleLines - break the output into multiple lines to be more human-readable;
SingleLine mode may still result in multiple lines if the LineBreakThreshold is set to a small enough value.
Gets or sets a boolean value indicting whether to add a semicolon at the end of the parsed code (true) or not (false, default)
Gets or sets a long integer value containing kill switch flags for each individual mod to the parsed code tree. Allows for
callers to turn off specific modifications if desired. Default is 0, meaning no kill switches are set.
Gets an appropriate line-terminator string given the output mode
Gets a collection of errors to ignore
Set the collection of errors to ignore
collection of error code strings
number of error codes successfully added to the collection
string representation of the list of debug lookups, comma-separated
dictionary of defines and their values
Set the collection of defined names for the preprocessor
array of defined name strings
number of names successfully added to the collection
Set the dictionary of preprocessor defines and values
dictionary to set
string representation of the list of names defined for the preprocessor, comma-separated
Collection of resource string objects
Gets the mapping of replacement token to value
Gets the mapping of replacement token fallback class to replacement value
Only add items from the other set to the collection if the key doesn't already exist.
(Previous sets are more specific than subsequent sets)
less-specific set of name/value replacement token pairs
Always add items from the other set, replacing any pre-existing items in the collection.
(Subsequent sets are more specific than previous sets)
more-specific set of name/value replacement token pairs
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
Looks up a localized string similar to : .
Looks up a localized string similar to Fallback character encoding failed.
Looks up a localized string similar to Invalid JSON JavaScript nodes encountered during output.
Looks up a localized string similar to run-time.
Looks up a localized string similar to coding.
Looks up a localized string similar to code.
Looks up a localized string similar to performance.
Looks up a localized string similar to improper technique.
Looks up a localized string similar to unknown ({0}).
Type of code to process
Unknown - cannot tell from output, input, or hint
JavaScript source code
CSS Stylesheet source code
A mix of input types; error condition
Source origin for the input file
Source file owned by the project
Source file is external to the project
CssFallback encodes invalid encoder characters as Unicode escapes:
\123456
up to six hexadecimal characters. If less then six characters, we'll
suffix the encoding with a space character, just un case the next character
could be mistaken for another hexadecimal digit.
To use this class, create an instance of it and set it to the EncoderFallback
property of your Encoding object. You may have to clone the Encoding object
in order to get write access to the EncoderFallback property.
var encoding = (Encoding)Encoding.ASCII.Clone();
encoding.EncoderFallback = new CssEncoderFallback();
var bytes = encoding.GetBytes(crunchedCode);
Console.WriteLine(encoding.GetString(bytes));
return a fallback buffer for this encoding fallback
the maximum number of characters we'll expand a single character into
fallback buffer for encoding unknown characters into CSS Unicode escapes
Number of characters remaining in the buffer
Get the single-character encoding string
character to encode
encoded string
Prepare the unknown character for encoding
character to process
position in input string
true if characters to process placed in buffer
Prepare the unknwon surrogate pair for encoding
high surrogate pair character
low surrogate pair character
index of character in the stream
return the next character
(char)0 if no character
back the character position up one character
false if already at front; true otherwise
reset the fallback buffer to initial state
Return string representation of this object
ColorSlice class
Parser takes Tokens and parses them into rules and statements
regular expression for matching first comment hack
This is the MacIE ignore bug: /*(anything or nothing inside)\*/.../*(anything or nothing inside)*/
Regular expression for matching second comment hack
Hide from everything EXCEPT Netscape 4 and Opera 5
Format: /*/*//*/.../*(anything or nothing inside)*/
Regular expression for matching third comment hack
Hide from Netscape 4
Format: /*/*/.../*(anything or nothing inside)*/
Regular expression for matching fourth comment hack
Hide from IE6
Format: property /*(anything or nothing inside)*/:value
WARNING: This does not actually parse the property/value -- it simply looks for a
word character followed by at least one whitespace character, followed
by a simple comment, followed by optional space, followed by a colon.
Does not match the simple word, the space or the colon (just the comment)
Regular expression for matching fifth comment hack
Hide from IE5.5
Format: property:/* (anything or nothing inside) */value
WARNING: This does not actually parse the property/value -- it simply looks for a
word character followed by optional whitespace character, followed
by a colon, followed by optional whitespace, followed by a simple comment.
Does not match initial word or the colon, just the comment.
Regular expression for matching sixth comment hack -- although not a real hack
Hide from IE6, NOT
Format: property/*(anything or nothing inside)*/:value
NOTE: This doesn't actually hide from IE6; it needs a space before the comment to actually work.
but enoough people code this in their CSS and expect it to be output that I recieved enough
requests to add it to the allowed "hacks"
WARNING: This does not actually parse the property/value -- it simply looks for a
word character followed by a simple comment, followed by optional space, followed by a colon.
Does not match the simple word or the colon (just initial whitespace and comment)
Regular expression for empty comments
These comments don't really do anything. But if the developer wrote an empty
comment (/**/ or /* */), then it has no documentation value and might possibly be
an attempted comment hack.
Format: /**/ or /* */ (single space)
matches 6-digit RGB color value where both r digits are the same, both
g digits are the same, and both b digits are the same (but r, g, and b
values are not necessarily the same). Used to identify #rrggbb values
that can be collapsed to #rgb
regular expression for matching css comments containing special formatted identifiers
for value-replacement matching
Format: /* [id] */
regular expression for matching Sharepoint Theme css comments
Format: /* [ReplaceBGImage] */
/* [id(parameters)] */
where id is one of: ReplaceColor, ReplaceFont, or RecolorImage
and parameters is anything other than a close square-bracket
Push a new string builder onto the builders stack
Pop the top waypoint off the stack.
If the Settings RemoveEmptyBlocks property is false, will keep the text, regardless of the passed-in setting.
true if push the text of the popped waypoint onto the new top waypoint; false to discard
true if the popped builder has any text within it
Get all the text that has been accumulting in the string builders
on the stack, unwinding the stack until it's empty
string representation of all parsed text
Returns true if the given property is vendor-specific and the vendor prefix
is in the list of excluded prefixes.
The property name
true if excluded; false otherwise
This method advances to the next token FIRST -- effectively skipping the current one --
and then skips any space tokens that FOLLOW it.
This method only skips the space that is already the current token.
true if space was skipped; false if the current token is not space
Always add new line to the stream
regular expression for matching newline characters
Scanner takes input stream and breaks it into Tokens
If the current character is a linebreak, eat it without advancing
our position.
Scan a preprocessing directive.
comment text
true if this is one of our preprocessing directives; false otherwise
Determines whether a given string is a valid vendor prefix. No hyphens allowed.
Given the current character is a %, see if it's followed by a syntax
that creates a valid replacement token. If so, return the token text.
if true, the current char is the delimiter and needs to be advanced;
false means we are already at the next character and shouldn't advance
valid token text, or null
returns the VALUE of a unicode number, up to six hex digits
int value representing up to 6 hex digits
Enumeration for the type of CSS that will be parsed
Default setting: expecting a full CSS stylesheet
Expecting just a declaration list, for instance: the value of an HTML style attribute
Remove all comments except those marked as important (//! or /*!)
Remove all source comments from the output
Keep all source comments in the output
Remove all source comments except those for approved comment-based hacks. (See documentation)
Enumeration for how to treat known color names
Convert strict names to hex values if shorter; hex values to strict names if shorter. Leave all other
color names or hex values as-specified.
Always use hex values; do not convert any hex values to color names
Convert known hex values to major-browser color names if shorter; and known major-browser color
names to hex if shorter.
Don't swap names for hex or hex for names, whether or not one is shorter.
Settings Object for CSS Uglify
Initializes a new instance of the class with default settings.
Gets or sets ColorNames setting. Default is Strict.
Gets or sets CommentMode setting. Default is Important.
Gets or sets a value indicating whether to minify the javascript within expression functions. Deault is true.
Gets or sets a value indicating how to treat the input source. Default is FullStyleSheet.
Gets or sets a value indicating whether empty blocks removes the corresponding rule or directive. Default is true.
Gets or sets a value indicating whether IE8 .EOT fonts should get a question-mark appended to the URL
(if not there already) to prevent the browser from generating invalid HTTP requests to the server. Default is true.
Gets or sets a list of vendor-specific prefixes ("ms", "webkit", "moz") that will be omitted from the output.
Default is no exclusions.
Gets or sets a value indicating whether a double-at Razor escape sequence is ignored.
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
Looks up a localized string similar to Color {0} can be collapsed to {1}.
Looks up a localized string similar to Decimal point not followed by numeric digit.
Looks up a localized string similar to declaration ignored.
Looks up a localized string similar to {0} ({1}).
Looks up a localized string similar to Duplicate namespace declaration; already declared '{0}'.
Looks up a localized string similar to Numeric value contains unnecessary characters: {0} is equivalent to {1}..
Looks up a localized string similar to Expected charset string, found '{0}'.
Looks up a localized string similar to Expected closing curly-brace, found '{0}'.
Looks up a localized string similar to Expected closing bracket, found '{0}'.
Looks up a localized string similar to Expected closing parenthesis, found '{0}'.
Looks up a localized string similar to Expected colon, found '{0}'.
Looks up a localized string similar to Expect comma, found '{0}'.
Looks up a localized string similar to Expected comma or open brace, found '{0}'.
Looks up a localized string similar to Expected comma or semi-colon, found '{0}'.
Looks up a localized string similar to Expected end of file; invalid input file.
Looks up a localized string similar to Expected equal sign, found {0}.
Looks up a localized string similar to Expected expression, found '{0}'.
Looks up a localized string similar to Expected function, found '{0}'.
Looks up a localized string similar to Expected hex color, found '{0}'.
Looks up a localized string similar to Expected identifier, found '{0}'.
Looks up a localized string similar to Expected identifier or string, found '{0}'.
Looks up a localized string similar to Expected import string or uri, found '{0}'.
Looks up a localized string similar to Expected media feature, found '{0}'.
Looks up a localized string similar to Expected media identifier, found '{0}'.
Looks up a localized string similar to Expected media query, found '{0}'.
Looks up a localized string similar to Expected media-query expression, found '{0}'.
Looks up a localized string similar to Expected namespace string or uri, found '{0}'.
Looks up a localized string similar to Expected number, found '{0}'.
Looks up a localized string similar to Expected open brace, found '{0}'.
Looks up a localized string similar to Expected opening parenthesis.
Looks up a localized string similar to Expected percentage, 'from', or 'to'; found '{0}'.
Looks up a localized string similar to Expected calculation product, found '{0}'.
Looks up a localized string similar to Expected progid, found '{0}'.
Looks up a localized string similar to Expected number or percentage value in rgb function, found '{0}'.
Looks up a localized string similar to Expected selector, found '{0}'.
Looks up a localized string similar to Expected semi-colon, found '{0}'.
Looks up a localized string similar to Expected semicolon or closing curly-brace, found '{0}'.
Looks up a localized string similar to Expected semi-colon or close brace, found '{0}'.
Looks up a localized string similar to Expected calculation sum, found '{0}'.
Looks up a localized string similar to Expected term, found {0}.
Looks up a localized string similar to Expected calculation unit, found '{0}'.
Looks up a localized string similar to JavaScript error in expression property: {0}.
Looks up a localized string similar to Browser hack generates invalid CSS.
Looks up a localized string similar to Hash ({0}) not allowed after unary operator.
Looks up a localized string similar to Unicode high-surrogate value (0x{0:x}) not immediately followed by unicode-escaped low-surrogate value.
Looks up a localized string similar to Unicode high-surrogate value (0x{0:x}) followed by invalid low-surrogate value: 0x{1:x}.
Looks up a localized string similar to Invalid Unicode Range Token: '{0}'.
Looks up a localized string similar to Media queries require a space between 'and' and the opening parenthesis: '{0}'.
Looks up a localized string similar to Parser.
Looks up a localized string similar to Byte-order mark at front of source indicates possible encoding issue..
Looks up a localized string similar to Possible cross-browser invalid class name: {0}.
Looks up a localized string similar to 'progid:' is an IE-only construct that generates invalid CSS.
Looks up a localized string similar to Scanner.
Looks up a localized string similar to Token not allowed after unary operator: '{0}'.
Looks up a localized string similar to Namespace used but not declared in a @namespace statement: '{0}'.
Looks up a localized string similar to An underscore is not a valid CSS1 or CSS2 identifier character.
Looks up a localized string similar to Unexpected at-keyword, found '{0}'.
Looks up a localized string similar to @charset must be very first token in file.
Looks up a localized string similar to Unexpected dimension: '{0}'.
Looks up a localized string similar to Unexpected end of file encountered.
Looks up a localized string similar to Unexpected escape sequence: \{0}.
Looks up a localized string similar to Unexpected function; only calc( or attr( allowed here, found '{0}'.
Looks up a localized string similar to Unexpected number character: {0}.
Looks up a localized string similar to Unexpected string character: {0}.
Looks up a localized string similar to Unexpected token, found '{0}'.
Looks up a localized string similar to ?.
Looks up a localized string similar to Unknown error.
Looks up a localized string similar to Unnecessary units on a value of zero.
Looks up a localized string similar to Unterminated comment..
Looks up a localized string similar to Unterminated string: {0}.
Token class represents a parsed token of information consumed by the parser
Static class for caching StringBuilders so we don't have to keep creating/destroying them all the time
Acquire a possibly-shared string builder instance
an empty string builder instance
Acquire a tringBuilder object with at least the given capacity. If the capacity
is less than or equal to our normal capacity, just return something from the pool.
Otherwise create a new string builder that will just get discarded when released.
minimum capacity
StringBuilder object
Extension method to add a method to StringBuilders that will release them back into the thread pool
StringBuilder instance to add back to the thread pool
Emit the opening tag of this element
Emit the closing tag of this element
Emit a self closing tag of this element (cannot be used with Start or Closing)
The XML ? processing instruction
Helper class to decode an entity.
Destructively unescape a string: remove HTML entity symbols except for & > <
The string data that will be changed by unescaping HTML entity symbols.
Scans an entity.
Returns number of chars matched.
Decodes the given HTML entity to the matching Unicode characters.
The entity without & and ; symbols, for example, copy.
The unicode character set or null if the entity was not recognized.
Decodes the given UTF-32 character code to the matching set of UTF-16 characters.
The unicode character set or null if the entity was not recognized.
Source: http://www.w3.org/html/wg/drafts/html/master/syntax.html#named-character-references
A HTML attribute.
A HTML CDATA block
A HTML comment node.
A DOCTYPE HTML tag.
A root document element.
Initializes a new instance of the class.
A HTML/XML open/close/self-closing tag.
Base class for a minimalistic HTML DOM suitable for removing text or extracting text.
Simplified HTML5 Parser that should handle tag omission correctly (e.g: p, li...etc.)
Initializes a new instance of the class.
The text.
Name of the source file.
Settings for Html minification.
Initializes a new instance of the class.
Gets or sets a value indicating whether to treat attributes as case sensitive. Default is false
Gets or sets a value indicating whether to collapse whitespaces. Default is true
Gets or sets a value indicating whether to remove comments. Default is true
Gets or sets a value indicating whether to remove optional tags (e.g: </p> or </li>). Default is true
Gets or sets a value indicating whether to remove invalid closing tags (tags with only a end tag and a missing start tag)
Gets or sets a value indicating whether to remove empty attributes with whitespace only characters.
Gets or sets a value indicating whether to remove quoted attributes when possible. Default is true
Gets or sets a value indicating whether to decode entity characters to their shorter character equivalents. Default is true
Gets or sets the quote character used for attribute values. Default is null, meaning that it will let the minifier decide which is best. Default is null
Gets or sets a value indicating whether to remove script/style type attribute. Default is true
Gets or sets a value indicating whether to use the short version of a boolean attribute if value is true. Default is true
Gets or sets a value indicating whether the parsing is occuring on an HTML fragment to avoid creating missing tags (like html, body, head). Default is false
Gets or sets a value indicating whether minify js inside <script> tags. Default is true using
Gets or sets the minify js settings.
Gets or sets a value indicating whether minify css inside <style> tags. Default is true using
Gets or sets a value indicating whether minify css inside style attribute.
Gets or sets the minify css settings.
Gets or sets a value indicating whether to output an indented html (for debug).
Gets or sets a value indicating whether to remove any JavaScript code (in script tag or in html attributes)
Gets the inline tags preserving spaces around (default: a, abbr, acronym, b, bdi,
bdo, big, button, cite, code, del, dfn, em, font, i, ins, kbd, label,
mark, math, nobr, q, rp, rt, s, samp, small, span, strike, strong, sub, sup,
svg, time, tt, u, var)
Gets or sets a value indicating whether to keep one space when collapsing.
true to keep one space when collapsing; otherwise, false.
Gets the tags with non collapsable whitespaces (default: pre, textarea)
Gets a list of regex that will be matched against a HTML comment content. If a regex matches a HTML comment content, the comment will be kept
Gets the list of tags that will be kept even if they have an optional start/end tag.
returns settings to output a pretty HTML
A delegate to check whether a end tag can be omitted.
The tag for which we want to test if a end tag can be omitted.
The next sibling or null if it is the last tag of its parent.
true if the end tag can be omitted; false otherwise
An HTML text node
HTML base class for text nodes.
HTML raw content.
Settings for extracting text from an HTML document using the function.
The extracted text will not contain structure (newlines), formatting (HTML tags) or Html escape (& for &, < for <)
Keeps the structure of the document by emitting newline when necessary
Keeps HTML formatting tags (e.g <em>)
Keeps HTML escape for special characters (& for &, < for <)
Class responsible from extracting only text nodes from an HTML document, used by function.
Initializes a new instance of the class.
The writer.
The options.
if writer is null
Location of a text in a HTML source file.
Initializes a new instance of the struct.
The file.
The position.
The line.
The column.
The source file name (may be null)
The absolute position from the begining of the file
The line position (start at 1)
The character position (start at 1) (warning, does not count tabs)
Settings for how local variables and functions can be renamed
Keep all names; don't rename anything
Rename all local variables and functions that do not begin with "L_"
Rename all local variables and functions. (default)
Settings for how to treat eval statements
Ignore all eval statements (default). This assumes that code that is eval'd will not attempt
to access any local variables or functions, as those variables and function may be renamed.
Assume any code that is eval'd will attempt to access local variables and functions declared
in the same scope as the eval statement. This will turn off local variable and function renaming
in any scope that contains an eval statement.
Assume that any local variable or function in any accessible scope chain may be referenced by
code that is eval'd. This will turn off local variable and function renaming for all scopes that
contain an eval statement, and all their parent scopes up the chain to the global scope.
Enum describing the type of input expected
Default input mode: a program, a block of top-level global statements
Input is a single JavaScript Expression
Input is an implicit function block, as in the value of an HTML onclick attribute
Input is an implicit module block, as referenced by an import statement
Enum describing how to treat the output JavaScript
normal JavaScript code
JSON code
Object used to store code settings for JavaScript parsing, minification, and output
Instantiate a CodeSettings object with the default settings
Instantiate a new CodeSettings object with the same settings as the current object.
a copy CodeSettings object
dictionary of identifiers we want to manually rename
Add a rename pair to the identifier rename map
name of the identifier in the source code
new name with which to replace the source name
true if added; false if either name is not a valid JavaScript identifier
Clear any rename pairs from the identifier rename map
returns whether or not there are any rename pairs in this settings object
Given a source identifier, return a new name for it, if one has already been added
source name to check
new name if it exists, null otherwise
Gets or sets a string representation of all the indentifier replacements as a comma-separated
list of "source=target" identifiers.
sets the collection of known global names to the enumeration of strings passed to this method
array of known global names
Get or sets the no-automatic-renaming list as a single string of comma-separated identifiers
Gets the known global name collection
sets the collection of known global names to the array of string passed to this method
collection of known global names
Add a known global identifier to the list
global identifier
true if valid identifier; false if invalid identifier
Gets or sets the known global names list as a single comma-separated string
Gets the set of debug lookups
Set the collection of debug "lookup" identifiers
collection of debug lookup identifier strings
number of names successfully added to the collection
string representation of the list of debug lookups, comma-separated
Gets or sets a flag indicating whether to always escape non-ASCII characters as \uXXXX
or to let the output encoding object handle that via the JsEncoderFallback object for the
specified output encoding format. Default is false (let the Encoding object handle it).
Gets or sets a value indicating whether to perform extra tasks on AMD-style defines.
collapse new Array() to [] and new Object() to {} [true]
or leave ais [false]. Default is true.
Gets or sets a boolean value indicating whether to use old-style const statements (just var-statements that
define unchangeable fields) or new EcmaScript 6 lexical declarations.
Throw an error if a source string is not safe for inclusion
in an HTML inline script block. Default is false.
Evaluate expressions containing only literal bool, string, numeric, or null values [true]
Leave literal expressions alone and do not evaluate them [false]. Default is true.
Gets or sets a settings value indicating how "safe" eval-statements are to be assumed.
Ignore (default) means we can assume eval-statements will not reference any local variables and functions.
MakeImmediateSafe assumes eval-statements will reference local variables and function within the same scope.
MakeAllSafe assumes eval-statements will reference any accessible local variable or function.
Local variables that we assume may be referenced by eval-statements cannot be automatically renamed.
Gets or sets the format to use for the JavaScript processing.
Gets or sets a boolean value indicating whether or not to ignore conditional-compilation comment syntax (true) or
to try to retain the comments in the output (false; default)
Gets or sets a boolean value indicating whether or not to ignore preprocessor defines comment syntax (true) or
to evaluate them (false; default)
Gets or sets a boolean value indicating whether to break up string literals containing </script> so inline code won't break [true, default]
or to leave string literals as-is [false]
Gets or sets a boolean value indicating whether/how local variables and functions should be automatically renamed:
KeepAll - do not rename local variables and functions;
CrunchAll - rename all local variables and functions to shorter names;
KeepLocalizationVars - rename all local variables and functions that do NOT start with L_
Gets or sets a boolean value indicating whether to add characters to the output to make sure Mac Safari bugs are not generated [true, default], or to
disregard potential known Mac Safari bugs in older versions [false]
Gets or sets a boolean value indicating whether any operations are to be applied to the parsed tree [true, default],
or whether to return it as-is [false].
Gets or sets a boolean value indicating whether object property names with the specified "from" names will
get renamed to the corresponding "to" names (true, default) when using the manual-rename feature, or left alone (false)
Gets or sets a boolean value indicating whether or not the input files should be preprocessed only (default is false)
Gets or sets a value indicating whether all function names must be preserved and remain as-named (true),
or can be automatically renamed (false, default).
Gets or sets a value indicating whether to preserve important comments in the output.
Default is true, preserving important comments. Important comments have an exclamation
mark as the very first in-comment character (//! or /*!).
Gets or sets a value indicating whether to always quote object literal property names.
Default is false.
Gets or sets a value indicating whether or not to reorder function and variable
declarations within scopes (true, default), or to leave the order as specified in
the original source.
Gets or sets a value indicating whether or not to remove unreferenced function expression names (true, default)
or to leave the names of function expressions, even if they are unreferenced (false).
Gets or sets a boolean value indicating whether to remove unneeded code, such as uncalled local functions or unreachable code [true, default],
or to keep such code in the output [false].
Gets or sets an enumeration that gives the parser a hint as to which version of EcmaScript standards to parse the source as.
See after parsing for which version the parser thought it had based on features found in the script.
Messages/warnings, and optimized output may change based on this settings value.
Gets or sets the source mode
Gets or sets a boolean value indicating whether or not to force the input code into strict mode (true)
or rely on the sources to turn on strict mode via the "use strict" prologue directive (false, default).
Gets or sets a boolean value indicating whether to strip debug statements [true, default],
or leave debug statements in the output [false]
Gets or sets the instance. Default is null, which won't output a symbol map.
Determine whether a particular AST tree modification is allowed, or has
been squelched (regardless of any other settings)
one or more tree modification settings
true only if NONE of the passed modifications have their kill bits set
Default. No specific tree modification
Preserve "important" comments in output: /*! ... */
Replace a member-bracket call with a member-dot construct if the member
name is a string literal that can be an identifier.
A["B"] ==> A.B
Replace a new Object constructor call with an object literal
new Object() ==> {}
Change Array constructor calls with array literals.
Does not replace constructors called with a single numeric parameter
(could be a capacity contructor call).
new Array() ==> []
new Array(A,B,C) ==> [A,B,C]
Remove the default case in a switch statement if the block contains
only a break statement.
remove default:break;
If there is no default case, remove any case statements that contain
only a single break statement.
remove case A:break;
Remove the break statement from the last case block of a switch statement.
switch(A){case B: C;break;} ==> switch(A){case B:C;}
Remove an empty finally statement if there is a non-empty catch block.
try{...}catch(E){...}finally{} ==> try{...}catch(E){...}
Remove duplicate var declarations in a var statement that have no initializers.
var A,A=B ==> var A=B
var A=B,A ==> var A=B
Combine adjacent var statements.
var A;var B ==> var A,B
Move preceeding var statement into the initializer of the for statement.
var A;for(var B;;); ==> for(var A,B;;);
var A;for(;;) ==> for(var A;;)
Combine adjacent var statement and return statement to a single return statement
var A=B;return A ==> return B
Replace an if-statement that has empty true and false branches with just the
condition expression.
if(A);else; ==> A;
replace if-statement that only has a single call statement in the true branch
with a logical-and statement
if(A)B() ==> A&&B()
Replace an if-else-statement where both branches are only a single return
statement with a single return statement and a conditional operator.
if(A)return B;else return C ==> return A?B:C
If a function ends in an if-statement that only has a true-branch containing
a single return statement with no operand, replace the if-statement with just
the condition expression.
function A(...){...;if(B)return} ==> function A(...){...;B}
If the true-block of an if-statment is empty and the else-block is not,
negate the condition and move the else-block to the true-block.
if(A);else B ==> if(!A)B
Combine adjacent string literals.
"A"+"B" ==> "AB"
Remove unary-plus operators when the operand is a numeric literal
+123 ==> 123
Apply (and cascade) unary-minus operators to the value of a numeric literal
-(4) ==> -4 (unary minus applied to a numeric 4 ==> numeric -4)
-(-4) ==> 4 (same as above, but cascading)
Apply minification technics to string literals
Apply minification techniques to numeric literals
Remove unused function parameters
remove "debug" statements
Rename local variables and functions
Remove unused function expression names
Remove unnecessary labels from break or continue statements
Remove unnecessary @cc_on statements
Convert (new Date()).getTime() to +new Date
Evaluate numeric literal expressions.
1 + 2 ==> 3
Simplify a common method on converting string to numeric:
lookup - 0 ==> +lookup
(Subtracting zero converts lookup to number, then doesn't modify
it; unary plus also converts operand to numeric)
Rename properties in object literals, member-dot, and member-bracket operations
Remove the quotes arounf objectl literal property names when
the names are valid identifiers.
Change boolean literals to not operators.
true -> !0
false -> !1
Change if-statements with expression statements as their branches to expressions
Combine adjacent expression statements into a single expression statement
using the comma operator
If the types of both sides of a strict operator (=== or !==) are known
to be the same, we can reduce the operators to == or !=
If the types of both sides of a strict operator (=== or !==) are known
to be different, than we can reduct the binary operator to false or true (respectively)
Move function declarations to the top of the containing scope
Combine var statements at the top of the containing scope
If the condition of an if-statement or conditional starts with a not-operator,
get rid of the not-operator and swap the true/false branches.
Whether it's okay to move an expression containing an in-operator into a for-statement.
Whether it's okay to convert function...{...if(cond)return;s1;s2} to function...{...if(!cond){s1;s2}}
Whether it's okay to combine nested if-statments if(cond1)if(cond2){...} to if(cond1&&cond2){...}
Whether it's okay to combine equivalent if-statments that return the same expression.
if(cond1)return expr;if(cond2)return expr; => if(cond1||cond2)return expr;
Whether to convert certain while-statements to for-statements.
while(1)... => for(;;)...
var ...;while(1)... => for(var ...;;)
var ...;while(cond)... => for(var ...;cond;)...
Whether to invert iterator{if(cond)continue;st1;st2} to iterator{if(!cond){st1;st2}}
Whether to convert [a,b,c].join(s) to "asbsc" if all items are constants.
Whether we should remove unused variable, or variables assigned a constant in their
initializer and referenced only once.
Whether we should unfold comma-separated expressions statements into separate statements
as a final minification step (if it doesn't create more bytes)
Whether to convert [a,b,c].length to 3 (if all items are constants)
and "123".length to 3
Whether to remove the "window." portion of a typeof operand
Whether to perform CultureInfo.CurrentCulture replacements on stand-alone and full-string tokens
get the algorithmically-generated minified variable name based on the given number
zero is the first name, 1 is the next, etc. This method needs to be tuned to
get better gzip results.
integer position of the name to retrieve
minified variable name
this class is used to sort the crunchable local fields in a scope so that the fields
most in need of crunching get crunched first, therefore having the smallest-length
crunched variable name.
Highest priority are the fields most-often referenced.
Among fields with the same reference count, the longest fields get priority.
Lastly, alphabetize.
sorting method for fields that will be renamed in the minification process.
The order of the fields determines which minified name it will receive --
the earlier in the list, typically the smaller, more-common the minified name.
Tune this method to get better gzip results.
Create a new document context from the given source
Gets the original name of the item, before renaming
Gets whether or not the item was renamed.
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
Looks up a localized string similar to Ambiguous catch identifier. Cross-browser behavior difference. .
Looks up a localized string similar to Ambiguous reference to named function expression. Cross-browser behavior difference.
Looks up a localized string similar to Application failed. Please report this issue..
Looks up a localized string similar to Argument defined but not referenced.
Looks up a localized string similar to Trailing comma in array literal; cross-browser difference.
Looks up a localized string similar to Arrow functions cannot be constructors.
Looks up a localized string similar to Assignment to constant.
Looks up a localized string similar to Invalid binding syntax.
Looks up a localized string similar to Can't have 'break' outside of loop.
Looks up a localized string similar to Can't have 'continue' outside of loop.
Looks up a localized string similar to Invalid hexadecimal escape sequence.
Looks up a localized string similar to Label redefined.
Looks up a localized string similar to Invalid numeric literal.
Looks up a localized string similar to 'return' statement outside of function.
Looks up a localized string similar to Missing 'case' or 'default' statement.
Looks up a localized string similar to Binding pattern requires initializer.
Looks up a localized string similar to Unmatched '@else'; no '@if' defined.
Looks up a localized string similar to Unmatched '@elif'; no '@if' defined.
Looks up a localized string similar to Unmatched '@end'; no '@if' defined.
Looks up a localized string similar to Conditional compilation is turned off.
Looks up a localized string similar to Expected class element.
Looks up a localized string similar to Conditional compilation expression not supported. Comment ignored.
Looks up a localized string similar to 'default' can only appear once in a 'switch' statement.
Looks up a localized string similar to Variable or function declaration redefines the catch error name.
Looks up a localized string similar to Duplicate class element name.
Looks up a localized string similar to Constant declaration already declared.
Looks up a localized string similar to Duplicate lexical declaration; cannot redefine let or const variables.
Looks up a localized string similar to Duplicate module declaration.
Looks up a localized string similar to Name is already defined.
Looks up a localized string similar to Expecting more source characters.
Looks up a localized string similar to Export statements must be at top level of module.
Looks up a localized string similar to Expected expression.
Looks up a localized string similar to Function expression expected.
Looks up a localized string similar to Function name should be a simple identifier; possible browser-specific implementation.
Looks up a localized string similar to Function defined but not referenced.
Looks up a localized string similar to High-surrogate pair value not followed by low-surrogate value.
Looks up a localized string similar to Illegal assignment.
Looks up a localized string similar to Invalid character.
Looks up a localized string similar to Implicit property name must be identifier.
Looks up a localized string similar to Import statement must include module name.
Looks up a localized string similar to Unmatched 'else'; no 'if' defined.
Looks up a localized string similar to JSParser Exception.
Looks up a localized string similar to Reserved words and should not be used as an identifier; cross-browser differences.
Looks up a localized string similar to Low-surrogate pair value not following a high-surrogate value.
Looks up a localized string similar to Methods not allowed in object literal bindings.
Looks up a localized string similar to Function declaration should not be inside a statement. Cross-browser behavior difference.
Looks up a localized string similar to Multiple default exports.
Looks up a localized string similar to New line not allowed.
Looks up a localized string similar to Expected binding syntax.
Looks up a localized string similar to Expected 'catch'.
Looks up a localized string similar to Expected '@end'.
Looks up a localized string similar to Expected ':'.
Looks up a localized string similar to Expected ','.
Looks up a localized string similar to Unterminated comment.
Looks up a localized string similar to Imported module has no default export.
Looks up a localized string similar to Expected ///#ENDDEBUG directive.
Looks up a localized string similar to Expected ///#ENDIF directive.
Looks up a localized string similar to Expected '='.
Looks up a localized string similar to Expected "from".
Looks up a localized string similar to Expected 'for' or 'if' keyword.
Looks up a localized string similar to Expected identifier.
Looks up a localized string similar to Label not found.
Looks up a localized string similar to Expected '{'.
Looks up a localized string similar to Expected '('.
Looks up a localized string similar to Expected identifier or string.
Looks up a localized string similar to Imported module does not export name.
Looks up a localized string similar to Expected ']'.
Looks up a localized string similar to Expected ',' or ']'.
Looks up a localized string similar to Expected '}'.
Looks up a localized string similar to Expected ')'.
Looks up a localized string similar to Expected ',' or ')'.
Looks up a localized string similar to Expected ';'.
Looks up a localized string similar to No source set on parser.
Looks up a localized string similar to Expected specifier set.
Looks up a localized string similar to Expected string literal.
Looks up a localized string similar to Expected 'while'.
Looks up a localized string similar to Consider replacing maximum numeric literal with Number.MAX_VALUE.
Looks up a localized string similar to Consider replacing minimum numeric literal with Number.MIN_VALUE.
Looks up a localized string similar to Numeric literal evaluates to Number.POSITIVE_INFINITY or Number.NEGATIVE_INFINITY.
Looks up a localized string similar to Object constructor should take no arguments.
Looks up a localized string similar to Reserved word used as object literal property name; cross-browser issue..
Looks up a localized string similar to Octal literals are deprecated. Possible cross-browser behavior difference.
Looks up a localized string similar to A variable argument list must be the last argument.
Looks up a localized string similar to Syntax error in regular expression.
Looks up a localized string similar to Resource reference must be single constant argument.
Looks up a localized string similar to Rest parameter can only be in last position.
Looks up a localized string similar to Semicolon insertion rules applied.
Looks up a localized string similar to Setter methods must have a single formal argument.
Looks up a localized string similar to Class constructor must be normal method.
Looks up a localized string similar to Always use full statement blocks.
Looks up a localized string similar to Class static method cannot be named "prototype".
Looks up a localized string similar to Strict operator always evaluates to true or false.
Looks up a localized string similar to Strict-mode does not allow certain argument names.
Looks up a localized string similar to Strict-mode does not allow certain catch binding names.
Looks up a localized string similar to Strict-mode does not allow duplicate argument names.
Looks up a localized string similar to Strict-mode does not allow duplicate property names.
Looks up a localized string similar to Strict-mode does not allow certain function names.
Looks up a localized string similar to Strict-mode does not allow assignment to certain variables.
Looks up a localized string similar to Strict-mode does not allow certain delete operands.
Looks up a localized string similar to Strict-mode does not allow ++ or -- on certain objects.
Looks up a localized string similar to Strict-mode does not allow with-statements.
Looks up a localized string similar to Strict-mode does not allow assignment to undefined variables.
Looks up a localized string similar to Strict-mode does not allow certain variable names.
Looks up a localized string similar to String literal is not safe for inline.
Looks up a localized string similar to Suspect assignment operator.
Looks up a localized string similar to Suspect equality comparison.
Looks up a localized string similar to Suspect semicolon.
Looks up a localized string similar to Syntax error.
Looks up a localized string similar to Too many errors. The file might not be a JavaScript file.
Looks up a localized string similar to Unable to convert from binding to reference.
Looks up a localized string similar to Unable to convert from reference to binding.
Looks up a localized string similar to End of file encountered before function is properly closed.
Looks up a localized string similar to Function has not been defined.
Looks up a localized string similar to Variable has not been declared.
Looks up a localized string similar to Unexpected ';'.
Looks up a localized string similar to Unterminated ASP.NET block.
Looks up a localized string similar to Unterminated string constant.
Looks up a localized string similar to Statement label never referenced.
Looks up a localized string similar to Variable defined but not referenced.
Looks up a localized string similar to 'with' statement not recommended.
super-simple JSON parser/validator. Exposes a Validate method
that takes a string and returns NULL if it isn't valid JSON, or
a string representing the original JSON text with any whitespace
removed.
Validate the given JSON string
JSON string to validate
null if not valid JSON; otherwise the original JSON text with whitespace removed
Class used to parse JavaScript source code into an abstract syntax tree.
Gets or sets a TextWriter instance to which raw preprocessed input will be
written when Parse is called.
Gets the array of timing points from a Parse run
Event sent whenever an error or warning is encountered during parsing
Sent for undefined references found during parsing
Creates an instance of the JavaScript parser object
Creates an instance of the JSParser class that can be used to parse the given source code.
Source code to parse.
Parse the given source context into an abstract syntax tree
source code with context
a Block object representing the series of statements in abstract syntax tree form
Parse the given source with context into an abstract syntax tree using the given settings
source code with context
settings to use for the parse operation
a Block object representing the series of statements in abstract syntax tree form
Parse the given source into an abstract syntax tree with no context
source code with no context
a Block object representing the series of statements in abstract syntax tree form
Parse the given source into an abstract syntax tree using the given settings
source code to parse
settings to use for the parse operation
a Block object representing the series of statements in abstract syntax tree form
Parse the source code using the given settings, getting back an abstract syntax tree Block node as the root
representing the list of statements in the source code.
code settings to use to process the source code
root Block node representing the top-level statements
Parse the document source using the scanner and settings that have all been set up already
through various combinations of constructor/properties/Parse methods.
Parsed Block node
Remove duplicate define calls, defined as defines with the same module name specified as the first
parameter, if it's a string literal. Only the last define with a given name is preserved.
script block to remove defines from; not recursed
set the source by creating a document from the actual source and its context,
then create and initialize a scanner for that document.
source code
optional context for the source code
Convert the given numeric string to a double value
string representation of a number
we should know alreasdy if it's an integer or not
output value
true if there were no problems; false if there were
Handle the expected semicolon at the current position for the given node.
node that should end with a semicolon
Generate a parser error.
The function is told whether or not next call to GetToken() should return the same
token or not
Error to report
true to move to the next token when GetNextToken is called; false to stay on this token
context to report against, or current token if null
whether to force to an error, or use the default severity
Gets or sets whether to use NUglify preprocessor defines or ignore them
Gets or sets whether to completely ignore IE conditional-compilation comments
Gets or sets whether to strip debug comment blocks entirely
Gets or sets whether to suppress all scanning errors
Gets the current line of the input file
Gets whether we have passed the end of the input source
Gets the position within the source of the start of the current line
Gets whether the scanned literal has potential cross-browser issues
Gets the current decoded string literal value
Gets the current decoded identifier string
Gets the current token reference
Clone for peek, reuse the same instance
Set the list of preprocessor defined names and values
dictionary of name/value pairs
main method for the scanner; scans the next token from the input stream.
next token from the input
Returns true if the character is between '0' and '9' inclusive.
Can't use char.IsDigit because that returns true for decimal digits in other language scripts as well.
character to test
true if in ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9']; false otherwise
Determines whether an unescaped string is a valid identifier.
escape sequences and surrogate pairs are accounted for.
potential identifier string
true if a valid JavaScript identifier; otherwise false
Determines if the character(s) at the given index is a valid identifier start
potential identifier string
index of the starting character
true if the character at the given position is a valid identifier start
Determines if the character(s) at the given index is a valid identifier start,
and adjust the index to point to the following character
potential identifier string
index of the starting character on entry; index of the NEXT character on exit
true if the character at the given position is a valid identifier start
Determines if the character(s) at the given index is a valid identifier part
potential identifier string
index of the starting character
true if the character at the given position is a valid identifier part
Determines if the character(s) at the given index is a valid identifier part,
and adjust the index to point to the following character
potential identifier string
index of the starting character on entry; index of the NEXT character on exit
true if the character at the given position is a valid identifier part
Determines whether the first character, surrogate pair, or escape sequence of the
given string represents a valid identifier part.
one or more characters
true if the first character represents a valid identifier part.
Determines if the given charater is a valid identifier part.
Does not work with extended UNICODE character
UTF-16 codepoint to test
true if the given character is a valid identifier part
Returns true of the given token is an assignment operator
token to test
true if the token is an assignment operator
Returns true if the given token is a right-associative operator
token to test
true if right-associative
determines whether a string is a replacement token value
string to tet
true if in the format %name(.name)*(:ident)?%
Scan an identifier starting at the current location, escaping any escape sequences
token scanned
Scans for the end of an Asp.Net block.
On exit this.currentPos will be at the next char to scan after the asp.net block.
skip to either the end of the line or the comment, whichever comes first, but
DON'T consume either of them.
Given a string and a start index, return the integer value of the UNICODE escape
sequence at the starting position. Can be '\' 'u' hex hex hex hex or '\' 'u' '{' hex+ '}'
text to convert
starting position of the escape backslash character on entry;
index of the next character after the escape sequence on exit
integer conversion of the valid escape sequence, or -1 if invalid
Given an assignment operator (=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, >>>=), strip
the assignment to return (+, -, *, /, %, &, |, ^, <<, >>, >>>). For all other operators,
include the normal assign (=), just return the same operator token.
This only works if the two groups of tokens are actually defined in those orders!!!
Class for associating an operator with a function for ///#IF directives
in a lazy-loaded manner. Doesn't create and initialize the dictionary
until the scanner actually encounters syntax that needs it.
The keys are sorted by length, decreasing (longest operators first).
Sorting class for the sorted dictionary base to make sure the operators are
enumerated with the LONGEST strings first, before the shorter strings.
Try converting the two strings to doubles
first string
second string
first string converted to double
second string converted to double
true if the conversion was successful; false otherwise
Field type enumeration
returns the only reference IF there is only ONE reference
in the collection; otherwise returns false.
returns the only declaration IF there is only ONE name declaration
in the collection; otherwise returns null.
Gets a value that indicates whether this field is ever referenced in a scope
other than the one in which it is defined
returns true if the fields point to the same ultimate reference object.
Needs to walk up the outer-reference chain for each field in order to
find the ultimate reference
Gets or sets an optional source root URI that will be added to the map object as the sourceRoot property if set
Gets or sets a flag indicating whether or not to add a "safe" header to the map output file
(not used by this implementation)
A new line has been inserted into the output code, so adjust the offsets accordingly
for the next run.
Signal the end of an output run by sending the NEXT position in the output
0-based line number
0-based column position
Gets and sets the output start line after running an AST through an output visitor
Gets and sets the output start column after running an AST through an output visitor
Create a new context by combining the current and other contexts
other context
new context instance
Trim off the first few characters of the context and return those characters
as a new context. Doesn't work if the length crosses a line boundary!
number of characters to trim off the front of this token
context for the trimmed-off portion
updates the current context with the other context
other context
current context for chaining purposes
Return the default severity for a given JSError value
guide: 0 == there will be a run-time error if this code executes
1 == the programmer probably did not intend to do this
2 == this can lead to cross-browser or future problems.
3 == this can lead to performance problems
4 == this is just not right
error code
severity
Create an instance of a source map writer of the given name and from the given base stream.
base stream
implementation name to create
instance of a source map writer
Array of strings which can be converted to string using a single allocation and single copy
Gets or sets a boolean value for whether this is an existing scope or a new one
generated during the current run.
Delete a binding from its parent pattern
binding to delete
true to normalize the parent pattern and possibly delete it if now empty
true if deleted, otherwise false
Set up this scope's fields from the declarations it contains
Return the first Block node in the tree starting from the given node and working up through the parent nodes.
initial node
first block node in the node tree
See if the given name will resolve to a field; do not create any inner fields
or unknown global fields along the way.
name to resolve
an existing resolved field, or null if nothing exists
Resolve the name in this scope, or go up the chain adding inner fields
along the way until the final reference is found, creating an unknown global
field if necessary.
name to resolve
resolved variable field (should never be null)
Abstract syntax tree node
Gets or sets the parent node of this node in the abstract syntax tree
Gets or sets the source context of this node
the context of any terminating character parsed after this node
e.g. the semicolon after a statement or a comma in a parameter list
Gets a boolean flag indicating whether this node is an expression
Gets a boolean flag indicating whether this node is a constant expression
Gets or sets a flag indicating whether we have analyzed this statement and determined it
to be for a debug-only build
Gets or sets the order-execution index for the node's function scope
Gets the order precedence of this node, if it is an expression
Gets or sets a flag indicting whether this node is a declaration
Gets a boolean value representing whether this node is a Lookup node resolving to the global predefined window object.
Gets the syntax tree node representing the leftmost portion of this node's subtree.
Get the enclosing lexical scope for this node.
Gets a flag indicating whether or not this node has its own associated scope, or relies on a parent node's scope
Gets an enumeration representing the child nodes of this node in the abstract syntax tree
Returns true if the node contains an in-operator
Gets a valid indicating the primitive JavaScript type of this node, if known.
Replace this node's specified child with another given node.
Child node to be replaced
New node with which to replace the existing child node
true if the replacement succeeded; false otherwise
Abstract method to be implemented by every concrete class.
Returns true of the other object is equivalent to this object
Gets a boolean value representing whether this node is a Lookup node resolving to the global name, or
a member off the global window object with the given name.
Abstract method to be implemented by every concrete node class
visitor to accept
an astlist is equivalent to another astlist if they both have the same number of
items, and each item is equivalent to the corresponding item in the other
Returns true if the expression contains an in-operator
Simple Binding identifier node class. Represents a name that is declared in a binding (parameter, vardecl, catch, etc)
Gets or sets the name of the binding
Gets or sets the field corresponding to this declaration
Gets or sets whether or not this declaration can be renamed
Gets or sets the scope type for this declaration (lexical or variable)
Gets any initializer that may be associated with this binding identifier
Gets or sets whether this binding identifier is a parameter name
Gets the original name of the identifier, before any renaming
Gets whether or not the item was renamed
Set up this scopes lexically-declared fields
Block of statements
Gets a particular statement in the list of statements making up this block
zero-based index of the desired statement
abstract syntax tree node
Gets the count of statements making up this block
Gets or sets a boolean value indicating whether the brace for this block (if there was one) started
on a newline (true) or the same line as the statement to which it belongs (false)
Gets or sets a flag indicating this this block is a module body
Gets or sets whether to force this block to always have curly-braces around it
and never to optimize them away.
Gets or sets whether this block is a concise block (has no braces)
Returns false unless the block constains only a single statement that is itself an expression.
Gets an enumerator for the syntax tree nodes making up this block
Remove all statements from the Block
Replace the existing direct child node of the block with a new node.
existing statement node to replace.
node with which to replace the existing node.
true if the replacement was a succeess; false otherwise
Append the given statement node to the end of the block
node to add to the block
Gets the zero-based index of the given syntax tree node within the block, or -1 if the node is not a direct child of the block
node to find
zero-based index of the node in the block, or -1 if the node is not a direct child of the block
Insert the given statement node after an existing node in the block.
exisitng child node of the block
node to insert after the existing node
Insert a new node into the given position index within the block
zero-based index into which the new node will be inserted
new node to insert into the block
Remove the last node in the block
Remove the node at the given position index.
Zero-based position index
Insert a set of nodes into the block at the given position
Zero-based position into which the new nodes will be inserted.
Collection of statements to insert
Class represents an EcmaScript 6 class node
Base class for ComprehensionForClause and ComprehensionIfClause
Optimized string literal concatenation for repeat usage pattern, avoiding multiple copying and allocation
Old-style const-statement, pre-ES6, for those browsers that basically implemented
a var that can't be assigned to outside the declaration. Have to set the
property to true to get these objects
parsed, because we default to the ES6 behavior.
This is a base-class for any custom AST nodes someone may want to implement. It allows
these nodes to be hooked into the IVisitor framework. If you wish to create custom AST nodes,
derive from this class.
Gets whether to add a semicolon after the node when another node follows this inside a block
Gets whether the custom node is a debugger statement and should be stripped for release builds
Returns true if any of the variable declarations contain initializers using the in-operator
Context for the first semicolon, separating the initializer and the condition
Context for the second semicolon, separating the condition and the incrementor
Gets or sets whether this function object is a generator
Gets or sets whether this function object is async
Check to see if this function is referenced. Perform a cyclic check
because being referenced by an unreferenced function is still unreferenced.
Set up this scopes lexically- and var-declared fields, plus formal parameters and the arguments object
Set up this scope's fields from the declarations it contains
Implementation of parenthetical '(' expr ')' operators
Gets the name that is declared for this specifier.
Only used if there was no local identifier defined and we added the external name to our scope.
Gets null; import specifiers are not parameters.
Only used if there was no local identifier defined and we added the external name to our scope.
Gets a flag indicating that this is not a parameter
Only used if there was no local identifier defined and we added the external name to our scope.
Gets a flag to indicate that imported external named cannot be renamed.
Only used if there was no local identifier defined and we added the external name to our scope.
Gets or sets a variable field corresponding to an import specifiers imported external name
Only used if there was no local identifier defined and we added the external name to our scope.
Initializer used in bindings
Gets the original name of the identifier, before any renaming
Gets whether or not the item was renamed
Gets or sets the identifier used when binding all of an external modules exports as properties on a local object
Gets or sets the module name
Gets or sets a flag indicating whether or not this module is an implicit module,
parsed as an external file that gets referenced by an import statement
Gets or sets a flag to indicate whether this module exports a default expression
Gets or sets a flag to indicate whether this module re-exports all exports from an unknown external module
Set up this scope's fields from the declarations it contains
Gets or sets parameter order position, zero-based
Gets or sets whether this parameter is prefixed with the rest token (...)
Gets or sets the source context for the rest token (if any)
Gets or sets the context for the optional default-value assignment token
Gets or sets the optional default value for the parameter
Summary description for variablestatement.
Set up this scopes lexically-declared fields
Standard JSON source map format, version 3
whether we have output a property yet
Gets or sets an optional source root URI that will be added to the map object as the sourceRoot property if set
Gets or sets a flag indicating whether or not to prepend the map file with an XSSI (cross-site script injection) protection string
Called when we start a new minified output file
output file path
Called when we end a minified output file. write all the accumulated
data to the stream.
A new line has been inserted into the output code, so adjust the offsets accordingly
for the next run.
Signal the end of an output run by sending the NEXT position in the output
0-based line number
0-based column position
For the given binding node, return a collection of individual INameDeclaration
nodes that represent the names being declared for this binding element.
binding node
collection of INameDeclaration nodes
For the given binding node, return a collection of individual lookup
nodes that represent the names being referenced.
binding node
collection of Lookup nodes
If the new literal is a string literal, then we need to check to see if our
parent is a CallNode. If it is, and if the string literal can be an identifier,
we'll replace it with a Member-Dot operation.
newLiteral we intend to replace this binaryop node with
true if we replaced the parent callnode with a member-dot operation
replace the node with a literal. If the node was wrapped in a grouping operator
before (parentheses around it), then we can get rid of the parentheses too, since
we are replacing the node with a single literal entity.
node to replace
literal to replace the node with
Both the operands of this operator are constants. See if we can evaluate them
left-side operand
right-side operand
We have determined that our left-hand operand is another binary operator, and its
right-hand operand is a constant that can be combined with our right-hand operand.
Now we want to set the right-hand operand of that other operator to the newly-
combined constant value, and then rotate it up -- replace our binary operator
with this newly-modified binary operator, and then attempt to re-evaluate it.
the binary operator that is our left-hand operand
the newly-combined literal
We have determined that our right-hand operand is another binary operator, and its
left-hand operand is a constant that can be combined with our left-hand operand.
Now we want to set the left-hand operand of that other operator to the newly-
combined constant value, and then rotate it up -- replace our binary operator
with this newly-modified binary operator, and then attempt to re-evaluate it.
the binary operator that is our right-hand operand
the newly-combined literal
Return true is not an overflow or underflow, for multiplication operations
left operand
right operand
result
true if result not overflow or underflow; false if it is
Return true if the result isn't an overflow condition
result constant
true is not an overflow; false if it is
Evaluate: (OTHER [op] CONST) [op] CONST
second constant
first constant
first operator
Evaluate: (CONST [op] OTHER) [op] CONST
second constant
first constant
first operator
Evaluate: CONST [op] (CONST [op] OTHER)
first constant
second constant
second operator
Eval the two constants: CONST [op] (OTHER [op] CONST)
first constant
second constant
second operator
output JSON-compatible code
output a new line and setup the proper indent level
This visitor has a Match method that takes a node and an string representing an identifier list separated by periods: IDENT(.IDENT)*
Determines whether or not a node needs parentheses around it within a new operator
Render a node tree to a text writer
writer to which to send output
node to render
settings to use for output
Render a node tree as a string
node to render
settings to use for output
string representation of the node
Output everything for a function except the initial keyword
outputs a semicolon for an empty block, just the statement for a single-statement block,
and recurses to the Block visitor for mutiple-statement blocks
block to output
Counts the number of double-quotes and single-quotes in a string
and returns a numeric indicator for which one should be used as
the string delimiter.
string to test
less than zero use single-quotes, zero or more, use double-quotes
Traverse the tree to build up scope lexically-declared names, var-declared names,
and lookups, then resolve everything.
index to use for ordering the statements in this scope
flag indicating whether we've encountered some unreachable code
depth level of with-statements, needed so we can treat decls within with-scopes specially
stack to maintain the current lexical scope as we traverse the tree
stack to maintain the current variable scope as we traverse the tree
code setings
language version of the script
Current lexical scope
current variable scope
retrieve the next order index
Determines if a node at the beginning of a statement needs parentheses around it
This is the flag that we are going to return to indicate whether or not
the statement start is safe (true) or requires parens (false)
JsEncoderFallback encodes invalid encoder characters as Unicode escapes:
\uXXXX
up to six characters per escape. If the UNICODE character is in the upper
range, we need to encode it as a surrogate pair:
\uUUUU\uLLLL
To use this class, create an instance of it and set it to the EncoderFallback
property of your Encoding object. You may have to clone the Encoding object
in order to get write access to the EncoderFallback property.
var encoding = (Encoding)Encoding.ASCII.Clone();
encoding.EncoderFallback = new JsEncoderFallback();
var bytes = encoding.GetBytes(crunchedCode);
Console.WriteLine(encoding.GetString(bytes));
return a fallback buffer for this encoding fallback
the maximum number of characters we'll expand a single character into
fallback buffer for encoding unknown characters into JS Unicode escapes
Number of characters remaining in the buffer
Get the single-character encoding string
character to encode
encoded string
Prepare the unknown character for encoding
character to process
position in input string
true if characters to process placed in buffer
Prepare the unknwon surrogate pair for encoding
high surrogate pair character
low surrogate pair character
index of character in the stream
return the next character
(char)0 if no character
back the character position up one character
false if already at front; true otherwise
reset the fallback buffer to initial state
Return string representation of this object
Output mode setting
Output the minified code on a single line for maximum minification.
LineBreakThreshold may still break the single line into multiple lines
at a syntactically correct point after the given line length is reached.
Not easily human-readable.
Output the minified code on multiple lines to increase readability
Supress code output; typically used for linting or analysis of source code
Uglify class for quick minification of JavaScript or Stylesheet code without needing to
access or modify any abstract syntax tree nodes. Just put in source code and get our minified
code as strings.
Crunched HTML string passed to it, returning crunched string.
source HTML
HTML minification settings
The source file name used when reporting errors. Default is null
minified HTML
Extract the text from a HTML string.
The source HTML
The options to extract the text.
The source file name used when reporting errors. Default is null
The text extracted from this HTML string
Crunched JS string passed to it, returning crunched string.
The ErrorList property will be set with any errors found during the minification process.
source Javascript
code minification settings
minified Javascript
Crunched JS string passed to it, returning crunched string.
The ErrorList property will be set with any errors found during the minification process.
source Javascript
File name to use in error reporting. Default is input
code minification settings
minified Javascript
Minifies the CSS stylesheet passes to it using the given settings, returning the minified results
The ErrorList property will be set with any errors found during the minification process.
CSS Source
File name to use in error reporting. Default is input
CSS minification settings
JS minification settings to use for expression-minification
Minified StyleSheet
Enumeration indicating how existing files will be treated
Existing files will be overwritten, but existing files marked with the read-only flag will not
Any existing file will be overwritten, regardless of the state of its read-only flag
Existing files will be preserved (not overwritten)
Gets the parsed JavaScript code settings object
Gets the parsed CSS settings object
Gets a boolean value indicating whether or not Analyze mode is specified (default is false)
Gets a string value indication the report format specified for analyze more (default is null)
Gets the path for the analyze scope report file (default is null, output to console)
Gets a boolean value indicating whether or not Pretty-Print mode is specified (default is false)
Gets or sets an integer value indicating the warning severity threshold for reporting. Default is zero (syntax errors only).
Gets or sets a flag indicating how existing files should be treated.
Gets the string output encoding name. Default is null, indicating the default output encoding should be used.
Gets the string input encoding name. Default is null, indicating the default output encoding should be used.
Takes a full command-line string and parses the switches into the appropriate settings objects
Takes an array of arguments and parses the switches into the appropriate settings objects
Convert the exception to a VisualStudio format error message
file(startline[-endline]?,startcol[-endcol]?):[ subcategory] category [errorcode]: message
Results of a or
operation.
Initializes a new instance of the struct.
The uglified code.
The Messages.
Gets the the uglified code. May ne null if is true.
Gets a value indicating whether this instance has Messages.
Gets the Messages. Empty if no Messages.