2022-01-21 08:28:41 +00:00
( function webpackUniversalModuleDefinition ( root , factory ) {
if ( typeof exports === 'object' && typeof module === 'object' )
module . exports = factory ( ) ;
else if ( typeof define === 'function' && define . amd )
define ( "beautifier" , [ ] , factory ) ;
else if ( typeof exports === 'object' )
exports [ "beautifier" ] = factory ( ) ;
else
root [ "beautifier" ] = factory ( ) ;
} ) ( typeof self !== 'undefined' ? self : typeof windows !== 'undefined' ? window : typeof global !== 'undefined' ? global : this , function ( ) {
return /******/ ( function ( ) { // webpackBootstrap
/******/ "use strict" ;
/******/ var _ _webpack _modules _ _ = ( [
/* 0 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
var js _beautify = _ _webpack _require _ _ ( 1 ) ;
var css _beautify = _ _webpack _require _ _ ( 16 ) ;
var html _beautify = _ _webpack _require _ _ ( 19 ) ;
function style _html ( html _source , options , js , css ) {
js = js || js _beautify ;
css = css || css _beautify ;
return html _beautify ( html _source , options , js , css ) ;
}
style _html . defaultOptions = html _beautify . defaultOptions ;
module . exports . js = js _beautify ;
module . exports . css = css _beautify ;
module . exports . html = style _html ;
/***/ } ) ,
/* 1 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Beautifier = ( _ _webpack _require _ _ ( 2 ) . Beautifier ) ,
Options = ( _ _webpack _require _ _ ( 6 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function js _beautify ( js _source _text , options ) {
var beautifier = new Beautifier ( js _source _text , options ) ;
return beautifier . beautify ( ) ;
}
module . exports = js _beautify ;
module . exports . defaultOptions = function ( ) {
return new Options ( ) ;
} ;
/***/ } ) ,
/* 2 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Output = ( _ _webpack _require _ _ ( 3 ) . Output ) ;
var Token = ( _ _webpack _require _ _ ( 4 ) . Token ) ;
2022-01-21 08:28:41 +00:00
var acorn = _ _webpack _require _ _ ( 5 ) ;
2022-04-07 13:41:52 +00:00
var Options = ( _ _webpack _require _ _ ( 6 ) . Options ) ;
var Tokenizer = ( _ _webpack _require _ _ ( 8 ) . Tokenizer ) ;
var line _starters = ( _ _webpack _require _ _ ( 8 ) . line _starters ) ;
var positionable _operators = ( _ _webpack _require _ _ ( 8 ) . positionable _operators ) ;
var TOKEN = ( _ _webpack _require _ _ ( 8 ) . TOKEN ) ;
2022-01-21 08:28:41 +00:00
function in _array ( what , arr ) {
return arr . indexOf ( what ) !== - 1 ;
}
function ltrim ( s ) {
return s . replace ( /^\s+/g , '' ) ;
}
function generateMapFromStrings ( list ) {
var result = { } ;
for ( var x = 0 ; x < list . length ; x ++ ) {
// make the mapped names underscored instead of dash
result [ list [ x ] . replace ( /-/g , '_' ) ] = list [ x ] ;
}
return result ;
}
function reserved _word ( token , word ) {
return token && token . type === TOKEN . RESERVED && token . text === word ;
}
function reserved _array ( token , words ) {
return token && token . type === TOKEN . RESERVED && in _array ( token . text , words ) ;
}
// Unsure of what they mean, but they work. Worth cleaning up in future.
var special _words = [ 'case' , 'return' , 'do' , 'if' , 'throw' , 'else' , 'await' , 'break' , 'continue' , 'async' ] ;
var validPositionValues = [ 'before-newline' , 'after-newline' , 'preserve-newline' ] ;
// Generate map from array
var OPERATOR _POSITION = generateMapFromStrings ( validPositionValues ) ;
var OPERATOR _POSITION _BEFORE _OR _PRESERVE = [ OPERATOR _POSITION . before _newline , OPERATOR _POSITION . preserve _newline ] ;
var MODE = {
BlockStatement : 'BlockStatement' , // 'BLOCK'
Statement : 'Statement' , // 'STATEMENT'
ObjectLiteral : 'ObjectLiteral' , // 'OBJECT',
ArrayLiteral : 'ArrayLiteral' , //'[EXPRESSION]',
ForInitializer : 'ForInitializer' , //'(FOR-EXPRESSION)',
Conditional : 'Conditional' , //'(COND-EXPRESSION)',
Expression : 'Expression' //'(EXPRESSION)'
} ;
function remove _redundant _indentation ( output , frame ) {
// This implementation is effective but has some issues:
// - can cause line wrap to happen too soon due to indent removal
// after wrap points are calculated
// These issues are minor compared to ugly indentation.
if ( frame . multiline _frame ||
frame . mode === MODE . ForInitializer ||
frame . mode === MODE . Conditional ) {
return ;
}
// remove one indent from each line inside this section
output . remove _indent ( frame . start _line _index ) ;
}
// we could use just string.split, but
// IE doesn't like returning empty strings
function split _linebreaks ( s ) {
//return s.split(/\x0d\x0a|\x0a/);
s = s . replace ( acorn . allLineBreaks , '\n' ) ;
var out = [ ] ,
idx = s . indexOf ( "\n" ) ;
while ( idx !== - 1 ) {
out . push ( s . substring ( 0 , idx ) ) ;
s = s . substring ( idx + 1 ) ;
idx = s . indexOf ( "\n" ) ;
}
if ( s . length ) {
out . push ( s ) ;
}
return out ;
}
function is _array ( mode ) {
return mode === MODE . ArrayLiteral ;
}
function is _expression ( mode ) {
return in _array ( mode , [ MODE . Expression , MODE . ForInitializer , MODE . Conditional ] ) ;
}
function all _lines _start _with ( lines , c ) {
for ( var i = 0 ; i < lines . length ; i ++ ) {
var line = lines [ i ] . trim ( ) ;
if ( line . charAt ( 0 ) !== c ) {
return false ;
}
}
return true ;
}
function each _line _matches _indent ( lines , indent ) {
var i = 0 ,
len = lines . length ,
line ;
for ( ; i < len ; i ++ ) {
line = lines [ i ] ;
// allow empty lines to pass through
if ( line && line . indexOf ( indent ) !== 0 ) {
return false ;
}
}
return true ;
}
function Beautifier ( source _text , options ) {
options = options || { } ;
this . _source _text = source _text || '' ;
this . _output = null ;
this . _tokens = null ;
this . _last _last _text = null ;
this . _flags = null ;
this . _previous _flags = null ;
this . _flag _store = null ;
this . _options = new Options ( options ) ;
}
Beautifier . prototype . create _flags = function ( flags _base , mode ) {
var next _indent _level = 0 ;
if ( flags _base ) {
next _indent _level = flags _base . indentation _level ;
if ( ! this . _output . just _added _newline ( ) &&
flags _base . line _indent _level > next _indent _level ) {
next _indent _level = flags _base . line _indent _level ;
}
}
var next _flags = {
mode : mode ,
parent : flags _base ,
last _token : flags _base ? flags _base . last _token : new Token ( TOKEN . START _BLOCK , '' ) , // last token text
last _word : flags _base ? flags _base . last _word : '' , // last TOKEN.WORD passed
declaration _statement : false ,
declaration _assignment : false ,
multiline _frame : false ,
inline _frame : false ,
if _block : false ,
else _block : false ,
2022-07-11 11:25:19 +00:00
class _start _block : false , // class A { INSIDE HERE } or class B extends C { INSIDE HERE }
2022-01-21 08:28:41 +00:00
do _block : false ,
do _while : false ,
import _block : false ,
in _case _statement : false , // switch(..){ INSIDE HERE }
in _case : false , // we're on the exact line with "case 0:"
case _body : false , // the indented case-action block
2022-04-07 13:41:52 +00:00
case _block : false , // the indented case-action block is wrapped with {}
2022-01-21 08:28:41 +00:00
indentation _level : next _indent _level ,
alignment : 0 ,
line _indent _level : flags _base ? flags _base . line _indent _level : next _indent _level ,
start _line _index : this . _output . get _line _number ( ) ,
ternary _depth : 0
} ;
return next _flags ;
} ;
Beautifier . prototype . _reset = function ( source _text ) {
var baseIndentString = source _text . match ( /^[\t ]*/ ) [ 0 ] ;
this . _last _last _text = '' ; // pre-last token text
this . _output = new Output ( this . _options , baseIndentString ) ;
// If testing the ignore directive, start with output disable set to true
this . _output . raw = this . _options . test _output _raw ;
// Stack of parsing/formatting states, including MODE.
// We tokenize, parse, and output in an almost purely a forward-only stream of token input
// and formatted output. This makes the beautifier less accurate than full parsers
// but also far more tolerant of syntax errors.
//
// For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
// MODE.BlockStatement on the the stack, even though it could be object literal. If we later
// encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
// most full parsers would die, but the beautifier gracefully falls back to
// MODE.BlockStatement and continues on.
this . _flag _store = [ ] ;
this . set _mode ( MODE . BlockStatement ) ;
var tokenizer = new Tokenizer ( source _text , this . _options ) ;
this . _tokens = tokenizer . tokenize ( ) ;
return source _text ;
} ;
Beautifier . prototype . beautify = function ( ) {
// if disabled, return the input unchanged.
if ( this . _options . disabled ) {
return this . _source _text ;
}
var sweet _code ;
var source _text = this . _reset ( this . _source _text ) ;
var eol = this . _options . eol ;
if ( this . _options . eol === 'auto' ) {
eol = '\n' ;
if ( source _text && acorn . lineBreak . test ( source _text || '' ) ) {
eol = source _text . match ( acorn . lineBreak ) [ 0 ] ;
}
}
var current _token = this . _tokens . next ( ) ;
while ( current _token ) {
this . handle _token ( current _token ) ;
this . _last _last _text = this . _flags . last _token . text ;
this . _flags . last _token = current _token ;
current _token = this . _tokens . next ( ) ;
}
sweet _code = this . _output . get _code ( eol ) ;
return sweet _code ;
} ;
Beautifier . prototype . handle _token = function ( current _token , preserve _statement _flags ) {
if ( current _token . type === TOKEN . START _EXPR ) {
this . handle _start _expr ( current _token ) ;
} else if ( current _token . type === TOKEN . END _EXPR ) {
this . handle _end _expr ( current _token ) ;
} else if ( current _token . type === TOKEN . START _BLOCK ) {
this . handle _start _block ( current _token ) ;
} else if ( current _token . type === TOKEN . END _BLOCK ) {
this . handle _end _block ( current _token ) ;
} else if ( current _token . type === TOKEN . WORD ) {
this . handle _word ( current _token ) ;
} else if ( current _token . type === TOKEN . RESERVED ) {
this . handle _word ( current _token ) ;
} else if ( current _token . type === TOKEN . SEMICOLON ) {
this . handle _semicolon ( current _token ) ;
} else if ( current _token . type === TOKEN . STRING ) {
this . handle _string ( current _token ) ;
} else if ( current _token . type === TOKEN . EQUALS ) {
this . handle _equals ( current _token ) ;
} else if ( current _token . type === TOKEN . OPERATOR ) {
this . handle _operator ( current _token ) ;
} else if ( current _token . type === TOKEN . COMMA ) {
this . handle _comma ( current _token ) ;
} else if ( current _token . type === TOKEN . BLOCK _COMMENT ) {
this . handle _block _comment ( current _token , preserve _statement _flags ) ;
} else if ( current _token . type === TOKEN . COMMENT ) {
this . handle _comment ( current _token , preserve _statement _flags ) ;
} else if ( current _token . type === TOKEN . DOT ) {
this . handle _dot ( current _token ) ;
} else if ( current _token . type === TOKEN . EOF ) {
this . handle _eof ( current _token ) ;
} else if ( current _token . type === TOKEN . UNKNOWN ) {
this . handle _unknown ( current _token , preserve _statement _flags ) ;
} else {
this . handle _unknown ( current _token , preserve _statement _flags ) ;
}
} ;
Beautifier . prototype . handle _whitespace _and _comments = function ( current _token , preserve _statement _flags ) {
var newlines = current _token . newlines ;
var keep _whitespace = this . _options . keep _array _indentation && is _array ( this . _flags . mode ) ;
if ( current _token . comments _before ) {
var comment _token = current _token . comments _before . next ( ) ;
while ( comment _token ) {
// The cleanest handling of inline comments is to treat them as though they aren't there.
// Just continue formatting and the behavior should be logical.
// Also ignore unknown tokens. Again, this should result in better behavior.
this . handle _whitespace _and _comments ( comment _token , preserve _statement _flags ) ;
this . handle _token ( comment _token , preserve _statement _flags ) ;
comment _token = current _token . comments _before . next ( ) ;
}
}
if ( keep _whitespace ) {
for ( var i = 0 ; i < newlines ; i += 1 ) {
this . print _newline ( i > 0 , preserve _statement _flags ) ;
}
} else {
if ( this . _options . max _preserve _newlines && newlines > this . _options . max _preserve _newlines ) {
newlines = this . _options . max _preserve _newlines ;
}
if ( this . _options . preserve _newlines ) {
if ( newlines > 1 ) {
this . print _newline ( false , preserve _statement _flags ) ;
for ( var j = 1 ; j < newlines ; j += 1 ) {
this . print _newline ( true , preserve _statement _flags ) ;
}
}
}
}
} ;
var newline _restricted _tokens = [ 'async' , 'break' , 'continue' , 'return' , 'throw' , 'yield' ] ;
Beautifier . prototype . allow _wrap _or _preserved _newline = function ( current _token , force _linewrap ) {
force _linewrap = ( force _linewrap === undefined ) ? false : force _linewrap ;
// Never wrap the first token on a line
if ( this . _output . just _added _newline ( ) ) {
return ;
}
var shouldPreserveOrForce = ( this . _options . preserve _newlines && current _token . newlines ) || force _linewrap ;
var operatorLogicApplies = in _array ( this . _flags . last _token . text , positionable _operators ) ||
in _array ( current _token . text , positionable _operators ) ;
if ( operatorLogicApplies ) {
var shouldPrintOperatorNewline = (
in _array ( this . _flags . last _token . text , positionable _operators ) &&
in _array ( this . _options . operator _position , OPERATOR _POSITION _BEFORE _OR _PRESERVE )
) ||
in _array ( current _token . text , positionable _operators ) ;
shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline ;
}
if ( shouldPreserveOrForce ) {
this . print _newline ( false , true ) ;
} else if ( this . _options . wrap _line _length ) {
if ( reserved _array ( this . _flags . last _token , newline _restricted _tokens ) ) {
// These tokens should never have a newline inserted
// between them and the following expression.
return ;
}
this . _output . set _wrap _point ( ) ;
}
} ;
Beautifier . prototype . print _newline = function ( force _newline , preserve _statement _flags ) {
if ( ! preserve _statement _flags ) {
if ( this . _flags . last _token . text !== ';' && this . _flags . last _token . text !== ',' && this . _flags . last _token . text !== '=' && ( this . _flags . last _token . type !== TOKEN . OPERATOR || this . _flags . last _token . text === '--' || this . _flags . last _token . text === '++' ) ) {
var next _token = this . _tokens . peek ( ) ;
while ( this . _flags . mode === MODE . Statement &&
! ( this . _flags . if _block && reserved _word ( next _token , 'else' ) ) &&
! this . _flags . do _block ) {
this . restore _mode ( ) ;
}
}
}
if ( this . _output . add _new _line ( force _newline ) ) {
this . _flags . multiline _frame = true ;
}
} ;
Beautifier . prototype . print _token _line _indentation = function ( current _token ) {
if ( this . _output . just _added _newline ( ) ) {
if ( this . _options . keep _array _indentation &&
current _token . newlines &&
( current _token . text === '[' || is _array ( this . _flags . mode ) ) ) {
this . _output . current _line . set _indent ( - 1 ) ;
this . _output . current _line . push ( current _token . whitespace _before ) ;
this . _output . space _before _token = false ;
} else if ( this . _output . set _indent ( this . _flags . indentation _level , this . _flags . alignment ) ) {
this . _flags . line _indent _level = this . _flags . indentation _level ;
}
}
} ;
Beautifier . prototype . print _token = function ( current _token ) {
if ( this . _output . raw ) {
this . _output . add _raw _token ( current _token ) ;
return ;
}
if ( this . _options . comma _first && current _token . previous && current _token . previous . type === TOKEN . COMMA &&
this . _output . just _added _newline ( ) ) {
if ( this . _output . previous _line . last ( ) === ',' ) {
var popped = this . _output . previous _line . pop ( ) ;
// if the comma was already at the start of the line,
// pull back onto that line and reprint the indentation
if ( this . _output . previous _line . is _empty ( ) ) {
this . _output . previous _line . push ( popped ) ;
this . _output . trim ( true ) ;
this . _output . current _line . pop ( ) ;
this . _output . trim ( ) ;
}
// add the comma in front of the next token
this . print _token _line _indentation ( current _token ) ;
this . _output . add _token ( ',' ) ;
this . _output . space _before _token = true ;
}
}
this . print _token _line _indentation ( current _token ) ;
this . _output . non _breaking _space = true ;
this . _output . add _token ( current _token . text ) ;
if ( this . _output . previous _token _wrapped ) {
this . _flags . multiline _frame = true ;
}
} ;
Beautifier . prototype . indent = function ( ) {
this . _flags . indentation _level += 1 ;
this . _output . set _indent ( this . _flags . indentation _level , this . _flags . alignment ) ;
} ;
Beautifier . prototype . deindent = function ( ) {
if ( this . _flags . indentation _level > 0 &&
( ( ! this . _flags . parent ) || this . _flags . indentation _level > this . _flags . parent . indentation _level ) ) {
this . _flags . indentation _level -= 1 ;
this . _output . set _indent ( this . _flags . indentation _level , this . _flags . alignment ) ;
}
} ;
Beautifier . prototype . set _mode = function ( mode ) {
if ( this . _flags ) {
this . _flag _store . push ( this . _flags ) ;
this . _previous _flags = this . _flags ;
} else {
this . _previous _flags = this . create _flags ( null , mode ) ;
}
this . _flags = this . create _flags ( this . _previous _flags , mode ) ;
this . _output . set _indent ( this . _flags . indentation _level , this . _flags . alignment ) ;
} ;
Beautifier . prototype . restore _mode = function ( ) {
if ( this . _flag _store . length > 0 ) {
this . _previous _flags = this . _flags ;
this . _flags = this . _flag _store . pop ( ) ;
if ( this . _previous _flags . mode === MODE . Statement ) {
remove _redundant _indentation ( this . _output , this . _previous _flags ) ;
}
this . _output . set _indent ( this . _flags . indentation _level , this . _flags . alignment ) ;
}
} ;
Beautifier . prototype . start _of _object _property = function ( ) {
return this . _flags . parent . mode === MODE . ObjectLiteral && this . _flags . mode === MODE . Statement && (
( this . _flags . last _token . text === ':' && this . _flags . ternary _depth === 0 ) || ( reserved _array ( this . _flags . last _token , [ 'get' , 'set' ] ) ) ) ;
} ;
Beautifier . prototype . start _of _statement = function ( current _token ) {
var start = false ;
start = start || reserved _array ( this . _flags . last _token , [ 'var' , 'let' , 'const' ] ) && current _token . type === TOKEN . WORD ;
start = start || reserved _word ( this . _flags . last _token , 'do' ) ;
start = start || ( ! ( this . _flags . parent . mode === MODE . ObjectLiteral && this . _flags . mode === MODE . Statement ) ) && reserved _array ( this . _flags . last _token , newline _restricted _tokens ) && ! current _token . newlines ;
start = start || reserved _word ( this . _flags . last _token , 'else' ) &&
! ( reserved _word ( current _token , 'if' ) && ! current _token . comments _before ) ;
start = start || ( this . _flags . last _token . type === TOKEN . END _EXPR && ( this . _previous _flags . mode === MODE . ForInitializer || this . _previous _flags . mode === MODE . Conditional ) ) ;
start = start || ( this . _flags . last _token . type === TOKEN . WORD && this . _flags . mode === MODE . BlockStatement &&
! this . _flags . in _case &&
! ( current _token . text === '--' || current _token . text === '++' ) &&
this . _last _last _text !== 'function' &&
current _token . type !== TOKEN . WORD && current _token . type !== TOKEN . RESERVED ) ;
start = start || ( this . _flags . mode === MODE . ObjectLiteral && (
( this . _flags . last _token . text === ':' && this . _flags . ternary _depth === 0 ) || reserved _array ( this . _flags . last _token , [ 'get' , 'set' ] ) ) ) ;
if ( start ) {
this . set _mode ( MODE . Statement ) ;
this . indent ( ) ;
this . handle _whitespace _and _comments ( current _token , true ) ;
// Issue #276:
// If starting a new statement with [if, for, while, do], push to a new line.
// if (a) if (b) if(c) d(); else e(); else f();
if ( ! this . start _of _object _property ( ) ) {
this . allow _wrap _or _preserved _newline ( current _token ,
reserved _array ( current _token , [ 'do' , 'for' , 'if' , 'while' ] ) ) ;
}
return true ;
}
return false ;
} ;
Beautifier . prototype . handle _start _expr = function ( current _token ) {
// The conditional starts the statement if appropriate.
if ( ! this . start _of _statement ( current _token ) ) {
this . handle _whitespace _and _comments ( current _token ) ;
}
var next _mode = MODE . Expression ;
if ( current _token . text === '[' ) {
if ( this . _flags . last _token . type === TOKEN . WORD || this . _flags . last _token . text === ')' ) {
// this is array index specifier, break immediately
// a[x], fn()[x]
if ( reserved _array ( this . _flags . last _token , line _starters ) ) {
this . _output . space _before _token = true ;
}
this . print _token ( current _token ) ;
this . set _mode ( next _mode ) ;
this . indent ( ) ;
if ( this . _options . space _in _paren ) {
this . _output . space _before _token = true ;
}
return ;
}
next _mode = MODE . ArrayLiteral ;
if ( is _array ( this . _flags . mode ) ) {
if ( this . _flags . last _token . text === '[' ||
( this . _flags . last _token . text === ',' && ( this . _last _last _text === ']' || this . _last _last _text === '}' ) ) ) {
// ], [ goes to new line
// }, [ goes to new line
if ( ! this . _options . keep _array _indentation ) {
this . print _newline ( ) ;
}
}
}
if ( ! in _array ( this . _flags . last _token . type , [ TOKEN . START _EXPR , TOKEN . END _EXPR , TOKEN . WORD , TOKEN . OPERATOR , TOKEN . DOT ] ) ) {
this . _output . space _before _token = true ;
}
} else {
if ( this . _flags . last _token . type === TOKEN . RESERVED ) {
if ( this . _flags . last _token . text === 'for' ) {
this . _output . space _before _token = this . _options . space _before _conditional ;
next _mode = MODE . ForInitializer ;
} else if ( in _array ( this . _flags . last _token . text , [ 'if' , 'while' , 'switch' ] ) ) {
this . _output . space _before _token = this . _options . space _before _conditional ;
next _mode = MODE . Conditional ;
} else if ( in _array ( this . _flags . last _word , [ 'await' , 'async' ] ) ) {
// Should be a space between await and an IIFE, or async and an arrow function
this . _output . space _before _token = true ;
} else if ( this . _flags . last _token . text === 'import' && current _token . whitespace _before === '' ) {
this . _output . space _before _token = false ;
} else if ( in _array ( this . _flags . last _token . text , line _starters ) || this . _flags . last _token . text === 'catch' ) {
this . _output . space _before _token = true ;
}
} else if ( this . _flags . last _token . type === TOKEN . EQUALS || this . _flags . last _token . type === TOKEN . OPERATOR ) {
// Support of this kind of newline preservation.
// a = (b &&
// (c || d));
if ( ! this . start _of _object _property ( ) ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
} else if ( this . _flags . last _token . type === TOKEN . WORD ) {
this . _output . space _before _token = false ;
// function name() vs function name ()
// function* name() vs function* name ()
// async name() vs async name ()
// In ES6, you can also define the method properties of an object
// var obj = {a: function() {}}
// It can be abbreviated
// var obj = {a() {}}
// var obj = { a() {}} vs var obj = { a () {}}
// var obj = { * a() {}} vs var obj = { * a () {}}
var peek _back _two = this . _tokens . peek ( - 3 ) ;
if ( this . _options . space _after _named _function && peek _back _two ) {
// peek starts at next character so -1 is current token
var peek _back _three = this . _tokens . peek ( - 4 ) ;
if ( reserved _array ( peek _back _two , [ 'async' , 'function' ] ) ||
( peek _back _two . text === '*' && reserved _array ( peek _back _three , [ 'async' , 'function' ] ) ) ) {
this . _output . space _before _token = true ;
} else if ( this . _flags . mode === MODE . ObjectLiteral ) {
if ( ( peek _back _two . text === '{' || peek _back _two . text === ',' ) ||
( peek _back _two . text === '*' && ( peek _back _three . text === '{' || peek _back _three . text === ',' ) ) ) {
this . _output . space _before _token = true ;
}
2022-07-11 11:25:19 +00:00
} else if ( this . _flags . parent && this . _flags . parent . class _start _block ) {
this . _output . space _before _token = true ;
2022-01-21 08:28:41 +00:00
}
}
} else {
// Support preserving wrapped arrow function expressions
// a.b('c',
// () => d.e
// )
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
// function() vs function ()
// yield*() vs yield* ()
// function*() vs function* ()
if ( ( this . _flags . last _token . type === TOKEN . RESERVED && ( this . _flags . last _word === 'function' || this . _flags . last _word === 'typeof' ) ) ||
( this . _flags . last _token . text === '*' &&
( in _array ( this . _last _last _text , [ 'function' , 'yield' ] ) ||
( this . _flags . mode === MODE . ObjectLiteral && in _array ( this . _last _last _text , [ '{' , ',' ] ) ) ) ) ) {
this . _output . space _before _token = this . _options . space _after _anon _function ;
}
}
if ( this . _flags . last _token . text === ';' || this . _flags . last _token . type === TOKEN . START _BLOCK ) {
this . print _newline ( ) ;
} else if ( this . _flags . last _token . type === TOKEN . END _EXPR || this . _flags . last _token . type === TOKEN . START _EXPR || this . _flags . last _token . type === TOKEN . END _BLOCK || this . _flags . last _token . text === '.' || this . _flags . last _token . type === TOKEN . COMMA ) {
// do nothing on (( and )( and ][ and ]( and .(
// TODO: Consider whether forcing this is required. Review failing tests when removed.
this . allow _wrap _or _preserved _newline ( current _token , current _token . newlines ) ;
}
this . print _token ( current _token ) ;
this . set _mode ( next _mode ) ;
if ( this . _options . space _in _paren ) {
this . _output . space _before _token = true ;
}
// In all cases, if we newline while inside an expression it should be indented.
this . indent ( ) ;
} ;
Beautifier . prototype . handle _end _expr = function ( current _token ) {
// statements inside expressions are not valid syntax, but...
// statements must all be closed when their container closes
while ( this . _flags . mode === MODE . Statement ) {
this . restore _mode ( ) ;
}
this . handle _whitespace _and _comments ( current _token ) ;
if ( this . _flags . multiline _frame ) {
this . allow _wrap _or _preserved _newline ( current _token ,
current _token . text === ']' && is _array ( this . _flags . mode ) && ! this . _options . keep _array _indentation ) ;
}
if ( this . _options . space _in _paren ) {
if ( this . _flags . last _token . type === TOKEN . START _EXPR && ! this . _options . space _in _empty _paren ) {
// () [] no inner space in empty parens like these, ever, ref #320
this . _output . trim ( ) ;
this . _output . space _before _token = false ;
} else {
this . _output . space _before _token = true ;
}
}
this . deindent ( ) ;
this . print _token ( current _token ) ;
this . restore _mode ( ) ;
remove _redundant _indentation ( this . _output , this . _previous _flags ) ;
// do {} while () // no statement required after
if ( this . _flags . do _while && this . _previous _flags . mode === MODE . Conditional ) {
this . _previous _flags . mode = MODE . Expression ;
this . _flags . do _block = false ;
this . _flags . do _while = false ;
}
} ;
Beautifier . prototype . handle _start _block = function ( current _token ) {
this . handle _whitespace _and _comments ( current _token ) ;
// Check if this is should be treated as a ObjectLiteral
var next _token = this . _tokens . peek ( ) ;
var second _token = this . _tokens . peek ( 1 ) ;
if ( this . _flags . last _word === 'switch' && this . _flags . last _token . type === TOKEN . END _EXPR ) {
this . set _mode ( MODE . BlockStatement ) ;
this . _flags . in _case _statement = true ;
} else if ( this . _flags . case _body ) {
this . set _mode ( MODE . BlockStatement ) ;
} else if ( second _token && (
( in _array ( second _token . text , [ ':' , ',' ] ) && in _array ( next _token . type , [ TOKEN . STRING , TOKEN . WORD , TOKEN . RESERVED ] ) ) ||
( in _array ( next _token . text , [ 'get' , 'set' , '...' ] ) && in _array ( second _token . type , [ TOKEN . WORD , TOKEN . RESERVED ] ) )
) ) {
// We don't support TypeScript,but we didn't break it for a very long time.
// We'll try to keep not breaking it.
2022-04-11 08:07:00 +00:00
if ( in _array ( this . _last _last _text , [ 'class' , 'interface' ] ) && ! in _array ( second _token . text , [ ':' , ',' ] ) ) {
2022-01-21 08:28:41 +00:00
this . set _mode ( MODE . BlockStatement ) ;
2022-04-11 08:07:00 +00:00
} else {
this . set _mode ( MODE . ObjectLiteral ) ;
2022-01-21 08:28:41 +00:00
}
} else if ( this . _flags . last _token . type === TOKEN . OPERATOR && this . _flags . last _token . text === '=>' ) {
// arrow function: (param1, paramN) => { statements }
this . set _mode ( MODE . BlockStatement ) ;
} else if ( in _array ( this . _flags . last _token . type , [ TOKEN . EQUALS , TOKEN . START _EXPR , TOKEN . COMMA , TOKEN . OPERATOR ] ) ||
reserved _array ( this . _flags . last _token , [ 'return' , 'throw' , 'import' , 'default' ] )
) {
// Detecting shorthand function syntax is difficult by scanning forward,
// so check the surrounding context.
// If the block is being returned, imported, export default, passed as arg,
// assigned with = or assigned in a nested object, treat as an ObjectLiteral.
this . set _mode ( MODE . ObjectLiteral ) ;
} else {
this . set _mode ( MODE . BlockStatement ) ;
}
2022-07-11 11:25:19 +00:00
if ( this . _flags . last _token ) {
if ( reserved _array ( this . _flags . last _token . previous , [ 'class' , 'extends' ] ) ) {
this . _flags . class _start _block = true ;
}
}
2022-01-21 08:28:41 +00:00
var empty _braces = ! next _token . comments _before && next _token . text === '}' ;
var empty _anonymous _function = empty _braces && this . _flags . last _word === 'function' &&
this . _flags . last _token . type === TOKEN . END _EXPR ;
if ( this . _options . brace _preserve _inline ) // check for inline, set inline_frame if so
{
// search forward for a newline wanted inside this block
var index = 0 ;
var check _token = null ;
this . _flags . inline _frame = true ;
do {
index += 1 ;
check _token = this . _tokens . peek ( index - 1 ) ;
if ( check _token . newlines ) {
this . _flags . inline _frame = false ;
break ;
}
} while ( check _token . type !== TOKEN . EOF &&
! ( check _token . type === TOKEN . END _BLOCK && check _token . opened === current _token ) ) ;
}
if ( ( this . _options . brace _style === "expand" ||
( this . _options . brace _style === "none" && current _token . newlines ) ) &&
! this . _flags . inline _frame ) {
if ( this . _flags . last _token . type !== TOKEN . OPERATOR &&
( empty _anonymous _function ||
this . _flags . last _token . type === TOKEN . EQUALS ||
( reserved _array ( this . _flags . last _token , special _words ) && this . _flags . last _token . text !== 'else' ) ) ) {
this . _output . space _before _token = true ;
} else {
this . print _newline ( false , true ) ;
}
} else { // collapse || inline_frame
if ( is _array ( this . _previous _flags . mode ) && ( this . _flags . last _token . type === TOKEN . START _EXPR || this . _flags . last _token . type === TOKEN . COMMA ) ) {
if ( this . _flags . last _token . type === TOKEN . COMMA || this . _options . space _in _paren ) {
this . _output . space _before _token = true ;
}
if ( this . _flags . last _token . type === TOKEN . COMMA || ( this . _flags . last _token . type === TOKEN . START _EXPR && this . _flags . inline _frame ) ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
this . _previous _flags . multiline _frame = this . _previous _flags . multiline _frame || this . _flags . multiline _frame ;
this . _flags . multiline _frame = false ;
}
}
if ( this . _flags . last _token . type !== TOKEN . OPERATOR && this . _flags . last _token . type !== TOKEN . START _EXPR ) {
2023-08-17 09:47:40 +00:00
if ( in _array ( this . _flags . last _token . type , [ TOKEN . START _BLOCK , TOKEN . SEMICOLON ] ) && ! this . _flags . inline _frame ) {
2022-01-21 08:28:41 +00:00
this . print _newline ( ) ;
} else {
this . _output . space _before _token = true ;
}
}
}
this . print _token ( current _token ) ;
this . indent ( ) ;
// Except for specific cases, open braces are followed by a new line.
if ( ! empty _braces && ! ( this . _options . brace _preserve _inline && this . _flags . inline _frame ) ) {
this . print _newline ( ) ;
}
} ;
Beautifier . prototype . handle _end _block = function ( current _token ) {
// statements must all be closed when their container closes
this . handle _whitespace _and _comments ( current _token ) ;
while ( this . _flags . mode === MODE . Statement ) {
this . restore _mode ( ) ;
}
var empty _braces = this . _flags . last _token . type === TOKEN . START _BLOCK ;
if ( this . _flags . inline _frame && ! empty _braces ) { // try inline_frame (only set if this._options.braces-preserve-inline) first
this . _output . space _before _token = true ;
} else if ( this . _options . brace _style === "expand" ) {
if ( ! empty _braces ) {
this . print _newline ( ) ;
}
} else {
// skip {}
if ( ! empty _braces ) {
if ( is _array ( this . _flags . mode ) && this . _options . keep _array _indentation ) {
// we REALLY need a newline here, but newliner would skip that
this . _options . keep _array _indentation = false ;
this . print _newline ( ) ;
this . _options . keep _array _indentation = true ;
} else {
this . print _newline ( ) ;
}
}
}
this . restore _mode ( ) ;
this . print _token ( current _token ) ;
} ;
Beautifier . prototype . handle _word = function ( current _token ) {
if ( current _token . type === TOKEN . RESERVED ) {
if ( in _array ( current _token . text , [ 'set' , 'get' ] ) && this . _flags . mode !== MODE . ObjectLiteral ) {
current _token . type = TOKEN . WORD ;
2022-04-11 08:07:00 +00:00
} else if ( current _token . text === 'import' && in _array ( this . _tokens . peek ( ) . text , [ '(' , '.' ] ) ) {
2022-01-21 08:28:41 +00:00
current _token . type = TOKEN . WORD ;
} else if ( in _array ( current _token . text , [ 'as' , 'from' ] ) && ! this . _flags . import _block ) {
current _token . type = TOKEN . WORD ;
} else if ( this . _flags . mode === MODE . ObjectLiteral ) {
var next _token = this . _tokens . peek ( ) ;
if ( next _token . text === ':' ) {
current _token . type = TOKEN . WORD ;
}
}
}
if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
if ( reserved _array ( this . _flags . last _token , [ 'var' , 'let' , 'const' ] ) && current _token . type === TOKEN . WORD ) {
this . _flags . declaration _statement = true ;
}
} else if ( current _token . newlines && ! is _expression ( this . _flags . mode ) &&
( this . _flags . last _token . type !== TOKEN . OPERATOR || ( this . _flags . last _token . text === '--' || this . _flags . last _token . text === '++' ) ) &&
this . _flags . last _token . type !== TOKEN . EQUALS &&
( this . _options . preserve _newlines || ! reserved _array ( this . _flags . last _token , [ 'var' , 'let' , 'const' , 'set' , 'get' ] ) ) ) {
this . handle _whitespace _and _comments ( current _token ) ;
this . print _newline ( ) ;
} else {
this . handle _whitespace _and _comments ( current _token ) ;
}
if ( this . _flags . do _block && ! this . _flags . do _while ) {
if ( reserved _word ( current _token , 'while' ) ) {
// do {} ## while ()
this . _output . space _before _token = true ;
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
this . _flags . do _while = true ;
return ;
} else {
// do {} should always have while as the next word.
// if we don't see the expected while, recover
this . print _newline ( ) ;
this . _flags . do _block = false ;
}
}
// if may be followed by else, or not
// Bare/inline ifs are tricky
// Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
if ( this . _flags . if _block ) {
if ( ! this . _flags . else _block && reserved _word ( current _token , 'else' ) ) {
this . _flags . else _block = true ;
} else {
while ( this . _flags . mode === MODE . Statement ) {
this . restore _mode ( ) ;
}
this . _flags . if _block = false ;
this . _flags . else _block = false ;
}
}
if ( this . _flags . in _case _statement && reserved _array ( current _token , [ 'case' , 'default' ] ) ) {
this . print _newline ( ) ;
2022-04-07 13:41:52 +00:00
if ( ! this . _flags . case _block && ( this . _flags . case _body || this . _options . jslint _happy ) ) {
2022-01-21 08:28:41 +00:00
// switch cases following one another
this . deindent ( ) ;
}
this . _flags . case _body = false ;
this . print _token ( current _token ) ;
this . _flags . in _case = true ;
return ;
}
if ( this . _flags . last _token . type === TOKEN . COMMA || this . _flags . last _token . type === TOKEN . START _EXPR || this . _flags . last _token . type === TOKEN . EQUALS || this . _flags . last _token . type === TOKEN . OPERATOR ) {
if ( ! this . start _of _object _property ( ) ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
}
if ( reserved _word ( current _token , 'function' ) ) {
if ( in _array ( this . _flags . last _token . text , [ '}' , ';' ] ) ||
( this . _output . just _added _newline ( ) && ! ( in _array ( this . _flags . last _token . text , [ '(' , '[' , '{' , ':' , '=' , ',' ] ) || this . _flags . last _token . type === TOKEN . OPERATOR ) ) ) {
// make sure there is a nice clean space of at least one blank line
// before a new function definition
if ( ! this . _output . just _added _blankline ( ) && ! current _token . comments _before ) {
this . print _newline ( ) ;
this . print _newline ( true ) ;
}
}
if ( this . _flags . last _token . type === TOKEN . RESERVED || this . _flags . last _token . type === TOKEN . WORD ) {
if ( reserved _array ( this . _flags . last _token , [ 'get' , 'set' , 'new' , 'export' ] ) ||
reserved _array ( this . _flags . last _token , newline _restricted _tokens ) ) {
this . _output . space _before _token = true ;
} else if ( reserved _word ( this . _flags . last _token , 'default' ) && this . _last _last _text === 'export' ) {
this . _output . space _before _token = true ;
} else if ( this . _flags . last _token . text === 'declare' ) {
// accomodates Typescript declare function formatting
this . _output . space _before _token = true ;
} else {
this . print _newline ( ) ;
}
} else if ( this . _flags . last _token . type === TOKEN . OPERATOR || this . _flags . last _token . text === '=' ) {
// foo = function
this . _output . space _before _token = true ;
} else if ( ! this . _flags . multiline _frame && ( is _expression ( this . _flags . mode ) || is _array ( this . _flags . mode ) ) ) {
// (function
} else {
this . print _newline ( ) ;
}
this . print _token ( current _token ) ;
this . _flags . last _word = current _token . text ;
return ;
}
var prefix = 'NONE' ;
if ( this . _flags . last _token . type === TOKEN . END _BLOCK ) {
if ( this . _previous _flags . inline _frame ) {
prefix = 'SPACE' ;
} else if ( ! reserved _array ( current _token , [ 'else' , 'catch' , 'finally' , 'from' ] ) ) {
prefix = 'NEWLINE' ;
} else {
if ( this . _options . brace _style === "expand" ||
this . _options . brace _style === "end-expand" ||
( this . _options . brace _style === "none" && current _token . newlines ) ) {
prefix = 'NEWLINE' ;
} else {
prefix = 'SPACE' ;
this . _output . space _before _token = true ;
}
}
} else if ( this . _flags . last _token . type === TOKEN . SEMICOLON && this . _flags . mode === MODE . BlockStatement ) {
// TODO: Should this be for STATEMENT as well?
prefix = 'NEWLINE' ;
} else if ( this . _flags . last _token . type === TOKEN . SEMICOLON && is _expression ( this . _flags . mode ) ) {
prefix = 'SPACE' ;
} else if ( this . _flags . last _token . type === TOKEN . STRING ) {
prefix = 'NEWLINE' ;
} else if ( this . _flags . last _token . type === TOKEN . RESERVED || this . _flags . last _token . type === TOKEN . WORD ||
( this . _flags . last _token . text === '*' &&
( in _array ( this . _last _last _text , [ 'function' , 'yield' ] ) ||
( this . _flags . mode === MODE . ObjectLiteral && in _array ( this . _last _last _text , [ '{' , ',' ] ) ) ) ) ) {
prefix = 'SPACE' ;
} else if ( this . _flags . last _token . type === TOKEN . START _BLOCK ) {
if ( this . _flags . inline _frame ) {
prefix = 'SPACE' ;
} else {
prefix = 'NEWLINE' ;
}
} else if ( this . _flags . last _token . type === TOKEN . END _EXPR ) {
this . _output . space _before _token = true ;
prefix = 'NEWLINE' ;
}
if ( reserved _array ( current _token , line _starters ) && this . _flags . last _token . text !== ')' ) {
if ( this . _flags . inline _frame || this . _flags . last _token . text === 'else' || this . _flags . last _token . text === 'export' ) {
prefix = 'SPACE' ;
} else {
prefix = 'NEWLINE' ;
}
}
if ( reserved _array ( current _token , [ 'else' , 'catch' , 'finally' ] ) ) {
if ( ( ! ( this . _flags . last _token . type === TOKEN . END _BLOCK && this . _previous _flags . mode === MODE . BlockStatement ) ||
this . _options . brace _style === "expand" ||
this . _options . brace _style === "end-expand" ||
( this . _options . brace _style === "none" && current _token . newlines ) ) &&
! this . _flags . inline _frame ) {
this . print _newline ( ) ;
} else {
this . _output . trim ( true ) ;
var line = this . _output . current _line ;
// If we trimmed and there's something other than a close block before us
// put a newline back in. Handles '} // comment' scenario.
if ( line . last ( ) !== '}' ) {
this . print _newline ( ) ;
}
this . _output . space _before _token = true ;
}
} else if ( prefix === 'NEWLINE' ) {
if ( reserved _array ( this . _flags . last _token , special _words ) ) {
// no newline between 'return nnn'
this . _output . space _before _token = true ;
} else if ( this . _flags . last _token . text === 'declare' && reserved _array ( current _token , [ 'var' , 'let' , 'const' ] ) ) {
// accomodates Typescript declare formatting
this . _output . space _before _token = true ;
} else if ( this . _flags . last _token . type !== TOKEN . END _EXPR ) {
if ( ( this . _flags . last _token . type !== TOKEN . START _EXPR || ! reserved _array ( current _token , [ 'var' , 'let' , 'const' ] ) ) && this . _flags . last _token . text !== ':' ) {
// no need to force newline on 'var': for (var x = 0...)
if ( reserved _word ( current _token , 'if' ) && reserved _word ( current _token . previous , 'else' ) ) {
// no newline for } else if {
this . _output . space _before _token = true ;
} else {
this . print _newline ( ) ;
}
}
} else if ( reserved _array ( current _token , line _starters ) && this . _flags . last _token . text !== ')' ) {
this . print _newline ( ) ;
}
} else if ( this . _flags . multiline _frame && is _array ( this . _flags . mode ) && this . _flags . last _token . text === ',' && this . _last _last _text === '}' ) {
this . print _newline ( ) ; // }, in lists get a newline treatment
} else if ( prefix === 'SPACE' ) {
this . _output . space _before _token = true ;
}
if ( current _token . previous && ( current _token . previous . type === TOKEN . WORD || current _token . previous . type === TOKEN . RESERVED ) ) {
this . _output . space _before _token = true ;
}
this . print _token ( current _token ) ;
this . _flags . last _word = current _token . text ;
if ( current _token . type === TOKEN . RESERVED ) {
if ( current _token . text === 'do' ) {
this . _flags . do _block = true ;
} else if ( current _token . text === 'if' ) {
this . _flags . if _block = true ;
} else if ( current _token . text === 'import' ) {
this . _flags . import _block = true ;
} else if ( this . _flags . import _block && reserved _word ( current _token , 'from' ) ) {
this . _flags . import _block = false ;
}
}
} ;
Beautifier . prototype . handle _semicolon = function ( current _token ) {
if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
// Semicolon can be the start (and end) of a statement
this . _output . space _before _token = false ;
} else {
this . handle _whitespace _and _comments ( current _token ) ;
}
var next _token = this . _tokens . peek ( ) ;
while ( this . _flags . mode === MODE . Statement &&
! ( this . _flags . if _block && reserved _word ( next _token , 'else' ) ) &&
! this . _flags . do _block ) {
this . restore _mode ( ) ;
}
// hacky but effective for the moment
if ( this . _flags . import _block ) {
this . _flags . import _block = false ;
}
this . print _token ( current _token ) ;
} ;
Beautifier . prototype . handle _string = function ( current _token ) {
if ( current _token . text . startsWith ( "`" ) && current _token . newlines === 0 && current _token . whitespace _before === '' && ( current _token . previous . text === ')' || this . _flags . last _token . type === TOKEN . WORD ) ) {
//Conditional for detectign backtick strings
} else if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
// One difference - strings want at least a space before
this . _output . space _before _token = true ;
} else {
this . handle _whitespace _and _comments ( current _token ) ;
if ( this . _flags . last _token . type === TOKEN . RESERVED || this . _flags . last _token . type === TOKEN . WORD || this . _flags . inline _frame ) {
this . _output . space _before _token = true ;
} else if ( this . _flags . last _token . type === TOKEN . COMMA || this . _flags . last _token . type === TOKEN . START _EXPR || this . _flags . last _token . type === TOKEN . EQUALS || this . _flags . last _token . type === TOKEN . OPERATOR ) {
if ( ! this . start _of _object _property ( ) ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
} else if ( ( current _token . text . startsWith ( "`" ) && this . _flags . last _token . type === TOKEN . END _EXPR && ( current _token . previous . text === ']' || current _token . previous . text === ')' ) && current _token . newlines === 0 ) ) {
this . _output . space _before _token = true ;
} else {
this . print _newline ( ) ;
}
}
this . print _token ( current _token ) ;
} ;
Beautifier . prototype . handle _equals = function ( current _token ) {
if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
} else {
this . handle _whitespace _and _comments ( current _token ) ;
}
if ( this . _flags . declaration _statement ) {
// just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
this . _flags . declaration _assignment = true ;
}
this . _output . space _before _token = true ;
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
} ;
Beautifier . prototype . handle _comma = function ( current _token ) {
this . handle _whitespace _and _comments ( current _token , true ) ;
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
if ( this . _flags . declaration _statement ) {
if ( is _expression ( this . _flags . parent . mode ) ) {
// do not break on comma, for(var a = 1, b = 2)
this . _flags . declaration _assignment = false ;
}
if ( this . _flags . declaration _assignment ) {
this . _flags . declaration _assignment = false ;
this . print _newline ( false , true ) ;
} else if ( this . _options . comma _first ) {
// for comma-first, we want to allow a newline before the comma
// to turn into a newline after the comma, which we will fixup later
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
} else if ( this . _flags . mode === MODE . ObjectLiteral ||
( this . _flags . mode === MODE . Statement && this . _flags . parent . mode === MODE . ObjectLiteral ) ) {
if ( this . _flags . mode === MODE . Statement ) {
this . restore _mode ( ) ;
}
if ( ! this . _flags . inline _frame ) {
this . print _newline ( ) ;
}
} else if ( this . _options . comma _first ) {
// EXPR or DO_BLOCK
// for comma-first, we want to allow a newline before the comma
// to turn into a newline after the comma, which we will fixup later
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
} ;
Beautifier . prototype . handle _operator = function ( current _token ) {
var isGeneratorAsterisk = current _token . text === '*' &&
( reserved _array ( this . _flags . last _token , [ 'function' , 'yield' ] ) ||
( in _array ( this . _flags . last _token . type , [ TOKEN . START _BLOCK , TOKEN . COMMA , TOKEN . END _BLOCK , TOKEN . SEMICOLON ] ) )
) ;
var isUnary = in _array ( current _token . text , [ '-' , '+' ] ) && (
in _array ( this . _flags . last _token . type , [ TOKEN . START _BLOCK , TOKEN . START _EXPR , TOKEN . EQUALS , TOKEN . OPERATOR ] ) ||
in _array ( this . _flags . last _token . text , line _starters ) ||
this . _flags . last _token . text === ','
) ;
if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
} else {
var preserve _statement _flags = ! isGeneratorAsterisk ;
this . handle _whitespace _and _comments ( current _token , preserve _statement _flags ) ;
}
// hack for actionscript's import .*;
if ( current _token . text === '*' && this . _flags . last _token . type === TOKEN . DOT ) {
this . print _token ( current _token ) ;
return ;
}
if ( current _token . text === '::' ) {
// no spaces around exotic namespacing syntax operator
this . print _token ( current _token ) ;
return ;
}
// Allow line wrapping between operators when operator_position is
// set to before or preserve
if ( this . _flags . last _token . type === TOKEN . OPERATOR && in _array ( this . _options . operator _position , OPERATOR _POSITION _BEFORE _OR _PRESERVE ) ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
if ( current _token . text === ':' && this . _flags . in _case ) {
this . print _token ( current _token ) ;
this . _flags . in _case = false ;
this . _flags . case _body = true ;
if ( this . _tokens . peek ( ) . type !== TOKEN . START _BLOCK ) {
this . indent ( ) ;
this . print _newline ( ) ;
2022-04-07 13:41:52 +00:00
this . _flags . case _block = false ;
2022-01-21 08:28:41 +00:00
} else {
2022-04-07 13:41:52 +00:00
this . _flags . case _block = true ;
2022-01-21 08:28:41 +00:00
this . _output . space _before _token = true ;
}
return ;
}
var space _before = true ;
var space _after = true ;
var in _ternary = false ;
if ( current _token . text === ':' ) {
if ( this . _flags . ternary _depth === 0 ) {
// Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
space _before = false ;
} else {
this . _flags . ternary _depth -= 1 ;
in _ternary = true ;
}
} else if ( current _token . text === '?' ) {
this . _flags . ternary _depth += 1 ;
}
// let's handle the operator_position option prior to any conflicting logic
if ( ! isUnary && ! isGeneratorAsterisk && this . _options . preserve _newlines && in _array ( current _token . text , positionable _operators ) ) {
var isColon = current _token . text === ':' ;
var isTernaryColon = ( isColon && in _ternary ) ;
var isOtherColon = ( isColon && ! in _ternary ) ;
switch ( this . _options . operator _position ) {
case OPERATOR _POSITION . before _newline :
// if the current token is : and it's not a ternary statement then we set space_before to false
this . _output . space _before _token = ! isOtherColon ;
this . print _token ( current _token ) ;
if ( ! isColon || isTernaryColon ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
this . _output . space _before _token = true ;
return ;
case OPERATOR _POSITION . after _newline :
// if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
// then print a newline.
this . _output . space _before _token = true ;
if ( ! isColon || isTernaryColon ) {
if ( this . _tokens . peek ( ) . newlines ) {
this . print _newline ( false , true ) ;
} else {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
} else {
this . _output . space _before _token = false ;
}
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
return ;
case OPERATOR _POSITION . preserve _newline :
if ( ! isOtherColon ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
// if we just added a newline, or the current token is : and it's not a ternary statement,
// then we set space_before to false
space _before = ! ( this . _output . just _added _newline ( ) || isOtherColon ) ;
this . _output . space _before _token = space _before ;
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
return ;
}
}
if ( isGeneratorAsterisk ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
space _before = false ;
var next _token = this . _tokens . peek ( ) ;
space _after = next _token && in _array ( next _token . type , [ TOKEN . WORD , TOKEN . RESERVED ] ) ;
} else if ( current _token . text === '...' ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
space _before = this . _flags . last _token . type === TOKEN . START _BLOCK ;
space _after = false ;
} else if ( in _array ( current _token . text , [ '--' , '++' , '!' , '~' ] ) || isUnary ) {
// unary operators (and binary +/- pretending to be unary) special cases
if ( this . _flags . last _token . type === TOKEN . COMMA || this . _flags . last _token . type === TOKEN . START _EXPR ) {
this . allow _wrap _or _preserved _newline ( current _token ) ;
}
space _before = false ;
space _after = false ;
// http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
// if there is a newline between -- or ++ and anything else we should preserve it.
2022-04-07 13:41:52 +00:00
if ( current _token . newlines && ( current _token . text === '--' || current _token . text === '++' || current _token . text === '~' ) ) {
2022-07-11 11:25:19 +00:00
var new _line _needed = reserved _array ( this . _flags . last _token , special _words ) && current _token . newlines ;
if ( new _line _needed && ( this . _previous _flags . if _block || this . _previous _flags . else _block ) ) {
this . restore _mode ( ) ;
}
this . print _newline ( new _line _needed , true ) ;
2022-01-21 08:28:41 +00:00
}
if ( this . _flags . last _token . text === ';' && is _expression ( this . _flags . mode ) ) {
// for (;; ++i)
// ^^^
space _before = true ;
}
if ( this . _flags . last _token . type === TOKEN . RESERVED ) {
space _before = true ;
} else if ( this . _flags . last _token . type === TOKEN . END _EXPR ) {
space _before = ! ( this . _flags . last _token . text === ']' && ( current _token . text === '--' || current _token . text === '++' ) ) ;
} else if ( this . _flags . last _token . type === TOKEN . OPERATOR ) {
// a++ + ++b;
// a - -b
space _before = in _array ( current _token . text , [ '--' , '-' , '++' , '+' ] ) && in _array ( this . _flags . last _token . text , [ '--' , '-' , '++' , '+' ] ) ;
// + and - are not unary when preceeded by -- or ++ operator
// a-- + b
// a * +b
// a - -b
if ( in _array ( current _token . text , [ '+' , '-' ] ) && in _array ( this . _flags . last _token . text , [ '--' , '++' ] ) ) {
space _after = true ;
}
}
if ( ( ( this . _flags . mode === MODE . BlockStatement && ! this . _flags . inline _frame ) || this . _flags . mode === MODE . Statement ) &&
( this . _flags . last _token . text === '{' || this . _flags . last _token . text === ';' ) ) {
// { foo; --i }
// foo(); --bar;
this . print _newline ( ) ;
}
}
this . _output . space _before _token = this . _output . space _before _token || space _before ;
this . print _token ( current _token ) ;
this . _output . space _before _token = space _after ;
} ;
Beautifier . prototype . handle _block _comment = function ( current _token , preserve _statement _flags ) {
if ( this . _output . raw ) {
this . _output . add _raw _token ( current _token ) ;
if ( current _token . directives && current _token . directives . preserve === 'end' ) {
// If we're testing the raw output behavior, do not allow a directive to turn it off.
this . _output . raw = this . _options . test _output _raw ;
}
return ;
}
if ( current _token . directives ) {
this . print _newline ( false , preserve _statement _flags ) ;
this . print _token ( current _token ) ;
if ( current _token . directives . preserve === 'start' ) {
this . _output . raw = true ;
}
this . print _newline ( false , true ) ;
return ;
}
// inline block
if ( ! acorn . newline . test ( current _token . text ) && ! current _token . newlines ) {
this . _output . space _before _token = true ;
this . print _token ( current _token ) ;
this . _output . space _before _token = true ;
return ;
} else {
this . print _block _commment ( current _token , preserve _statement _flags ) ;
}
} ;
Beautifier . prototype . print _block _commment = function ( current _token , preserve _statement _flags ) {
var lines = split _linebreaks ( current _token . text ) ;
var j ; // iterator for this case
var javadoc = false ;
var starless = false ;
var lastIndent = current _token . whitespace _before ;
var lastIndentLength = lastIndent . length ;
// block comment starts with a new line
this . print _newline ( false , preserve _statement _flags ) ;
// first line always indented
this . print _token _line _indentation ( current _token ) ;
this . _output . add _token ( lines [ 0 ] ) ;
this . print _newline ( false , preserve _statement _flags ) ;
if ( lines . length > 1 ) {
lines = lines . slice ( 1 ) ;
javadoc = all _lines _start _with ( lines , '*' ) ;
starless = each _line _matches _indent ( lines , lastIndent ) ;
if ( javadoc ) {
this . _flags . alignment = 1 ;
}
for ( j = 0 ; j < lines . length ; j ++ ) {
if ( javadoc ) {
// javadoc: reformat and re-indent
this . print _token _line _indentation ( current _token ) ;
this . _output . add _token ( ltrim ( lines [ j ] ) ) ;
} else if ( starless && lines [ j ] ) {
// starless: re-indent non-empty content, avoiding trim
this . print _token _line _indentation ( current _token ) ;
this . _output . add _token ( lines [ j ] . substring ( lastIndentLength ) ) ;
} else {
// normal comments output raw
this . _output . current _line . set _indent ( - 1 ) ;
this . _output . add _token ( lines [ j ] ) ;
}
// for comments on their own line or more than one line, make sure there's a new line after
this . print _newline ( false , preserve _statement _flags ) ;
}
this . _flags . alignment = 0 ;
}
} ;
Beautifier . prototype . handle _comment = function ( current _token , preserve _statement _flags ) {
if ( current _token . newlines ) {
this . print _newline ( false , preserve _statement _flags ) ;
} else {
this . _output . trim ( true ) ;
}
this . _output . space _before _token = true ;
this . print _token ( current _token ) ;
this . print _newline ( false , preserve _statement _flags ) ;
} ;
Beautifier . prototype . handle _dot = function ( current _token ) {
if ( this . start _of _statement ( current _token ) ) {
// The conditional starts the statement if appropriate.
} else {
this . handle _whitespace _and _comments ( current _token , true ) ;
}
2022-07-11 11:25:19 +00:00
if ( this . _flags . last _token . text . match ( '^[0-9]+$' ) ) {
this . _output . space _before _token = true ;
}
2022-01-21 08:28:41 +00:00
if ( reserved _array ( this . _flags . last _token , special _words ) ) {
this . _output . space _before _token = false ;
} else {
// allow preserved newlines before dots in general
// force newlines on dots after close paren when break_chained - for bar().baz()
this . allow _wrap _or _preserved _newline ( current _token ,
this . _flags . last _token . text === ')' && this . _options . break _chained _methods ) ;
}
// Only unindent chained method dot if this dot starts a new line.
// Otherwise the automatic extra indentation removal will handle the over indent
if ( this . _options . unindent _chained _methods && this . _output . just _added _newline ( ) ) {
this . deindent ( ) ;
}
this . print _token ( current _token ) ;
} ;
Beautifier . prototype . handle _unknown = function ( current _token , preserve _statement _flags ) {
this . print _token ( current _token ) ;
if ( current _token . text [ current _token . text . length - 1 ] === '\n' ) {
this . print _newline ( false , preserve _statement _flags ) ;
}
} ;
Beautifier . prototype . handle _eof = function ( current _token ) {
// Unwind any open statements
while ( this . _flags . mode === MODE . Statement ) {
this . restore _mode ( ) ;
}
this . handle _whitespace _and _comments ( current _token ) ;
} ;
module . exports . Beautifier = Beautifier ;
/***/ } ) ,
/* 3 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function OutputLine ( parent ) {
this . _ _parent = parent ;
this . _ _character _count = 0 ;
// use indent_count as a marker for this.__lines that have preserved indentation
this . _ _indent _count = - 1 ;
this . _ _alignment _count = 0 ;
this . _ _wrap _point _index = 0 ;
this . _ _wrap _point _character _count = 0 ;
this . _ _wrap _point _indent _count = - 1 ;
this . _ _wrap _point _alignment _count = 0 ;
this . _ _items = [ ] ;
}
OutputLine . prototype . clone _empty = function ( ) {
var line = new OutputLine ( this . _ _parent ) ;
line . set _indent ( this . _ _indent _count , this . _ _alignment _count ) ;
return line ;
} ;
OutputLine . prototype . item = function ( index ) {
if ( index < 0 ) {
return this . _ _items [ this . _ _items . length + index ] ;
} else {
return this . _ _items [ index ] ;
}
} ;
OutputLine . prototype . has _match = function ( pattern ) {
for ( var lastCheckedOutput = this . _ _items . length - 1 ; lastCheckedOutput >= 0 ; lastCheckedOutput -- ) {
if ( this . _ _items [ lastCheckedOutput ] . match ( pattern ) ) {
return true ;
}
}
return false ;
} ;
OutputLine . prototype . set _indent = function ( indent , alignment ) {
if ( this . is _empty ( ) ) {
this . _ _indent _count = indent || 0 ;
this . _ _alignment _count = alignment || 0 ;
this . _ _character _count = this . _ _parent . get _indent _size ( this . _ _indent _count , this . _ _alignment _count ) ;
}
} ;
OutputLine . prototype . _set _wrap _point = function ( ) {
if ( this . _ _parent . wrap _line _length ) {
this . _ _wrap _point _index = this . _ _items . length ;
this . _ _wrap _point _character _count = this . _ _character _count ;
this . _ _wrap _point _indent _count = this . _ _parent . next _line . _ _indent _count ;
this . _ _wrap _point _alignment _count = this . _ _parent . next _line . _ _alignment _count ;
}
} ;
OutputLine . prototype . _should _wrap = function ( ) {
return this . _ _wrap _point _index &&
this . _ _character _count > this . _ _parent . wrap _line _length &&
this . _ _wrap _point _character _count > this . _ _parent . next _line . _ _character _count ;
} ;
OutputLine . prototype . _allow _wrap = function ( ) {
if ( this . _should _wrap ( ) ) {
this . _ _parent . add _new _line ( ) ;
var next = this . _ _parent . current _line ;
next . set _indent ( this . _ _wrap _point _indent _count , this . _ _wrap _point _alignment _count ) ;
next . _ _items = this . _ _items . slice ( this . _ _wrap _point _index ) ;
this . _ _items = this . _ _items . slice ( 0 , this . _ _wrap _point _index ) ;
next . _ _character _count += this . _ _character _count - this . _ _wrap _point _character _count ;
this . _ _character _count = this . _ _wrap _point _character _count ;
if ( next . _ _items [ 0 ] === " " ) {
next . _ _items . splice ( 0 , 1 ) ;
next . _ _character _count -= 1 ;
}
return true ;
}
return false ;
} ;
OutputLine . prototype . is _empty = function ( ) {
return this . _ _items . length === 0 ;
} ;
OutputLine . prototype . last = function ( ) {
if ( ! this . is _empty ( ) ) {
return this . _ _items [ this . _ _items . length - 1 ] ;
} else {
return null ;
}
} ;
OutputLine . prototype . push = function ( item ) {
this . _ _items . push ( item ) ;
var last _newline _index = item . lastIndexOf ( '\n' ) ;
if ( last _newline _index !== - 1 ) {
this . _ _character _count = item . length - last _newline _index ;
} else {
this . _ _character _count += item . length ;
}
} ;
OutputLine . prototype . pop = function ( ) {
var item = null ;
if ( ! this . is _empty ( ) ) {
item = this . _ _items . pop ( ) ;
this . _ _character _count -= item . length ;
}
return item ;
} ;
OutputLine . prototype . _remove _indent = function ( ) {
if ( this . _ _indent _count > 0 ) {
this . _ _indent _count -= 1 ;
this . _ _character _count -= this . _ _parent . indent _size ;
}
} ;
OutputLine . prototype . _remove _wrap _indent = function ( ) {
if ( this . _ _wrap _point _indent _count > 0 ) {
this . _ _wrap _point _indent _count -= 1 ;
}
} ;
OutputLine . prototype . trim = function ( ) {
while ( this . last ( ) === ' ' ) {
this . _ _items . pop ( ) ;
this . _ _character _count -= 1 ;
}
} ;
OutputLine . prototype . toString = function ( ) {
var result = '' ;
if ( this . is _empty ( ) ) {
if ( this . _ _parent . indent _empty _lines ) {
result = this . _ _parent . get _indent _string ( this . _ _indent _count ) ;
}
} else {
result = this . _ _parent . get _indent _string ( this . _ _indent _count , this . _ _alignment _count ) ;
result += this . _ _items . join ( '' ) ;
}
return result ;
} ;
function IndentStringCache ( options , baseIndentString ) {
this . _ _cache = [ '' ] ;
this . _ _indent _size = options . indent _size ;
this . _ _indent _string = options . indent _char ;
if ( ! options . indent _with _tabs ) {
this . _ _indent _string = new Array ( options . indent _size + 1 ) . join ( options . indent _char ) ;
}
// Set to null to continue support for auto detection of base indent
baseIndentString = baseIndentString || '' ;
if ( options . indent _level > 0 ) {
baseIndentString = new Array ( options . indent _level + 1 ) . join ( this . _ _indent _string ) ;
}
this . _ _base _string = baseIndentString ;
this . _ _base _string _length = baseIndentString . length ;
}
IndentStringCache . prototype . get _indent _size = function ( indent , column ) {
var result = this . _ _base _string _length ;
column = column || 0 ;
if ( indent < 0 ) {
result = 0 ;
}
result += indent * this . _ _indent _size ;
result += column ;
return result ;
} ;
IndentStringCache . prototype . get _indent _string = function ( indent _level , column ) {
var result = this . _ _base _string ;
column = column || 0 ;
if ( indent _level < 0 ) {
indent _level = 0 ;
result = '' ;
}
column += indent _level * this . _ _indent _size ;
this . _ _ensure _cache ( column ) ;
result += this . _ _cache [ column ] ;
return result ;
} ;
IndentStringCache . prototype . _ _ensure _cache = function ( column ) {
while ( column >= this . _ _cache . length ) {
this . _ _add _column ( ) ;
}
} ;
IndentStringCache . prototype . _ _add _column = function ( ) {
var column = this . _ _cache . length ;
var indent = 0 ;
var result = '' ;
if ( this . _ _indent _size && column >= this . _ _indent _size ) {
indent = Math . floor ( column / this . _ _indent _size ) ;
column -= indent * this . _ _indent _size ;
result = new Array ( indent + 1 ) . join ( this . _ _indent _string ) ;
}
if ( column ) {
result += new Array ( column + 1 ) . join ( ' ' ) ;
}
this . _ _cache . push ( result ) ;
} ;
function Output ( options , baseIndentString ) {
this . _ _indent _cache = new IndentStringCache ( options , baseIndentString ) ;
this . raw = false ;
this . _end _with _newline = options . end _with _newline ;
this . indent _size = options . indent _size ;
this . wrap _line _length = options . wrap _line _length ;
this . indent _empty _lines = options . indent _empty _lines ;
this . _ _lines = [ ] ;
this . previous _line = null ;
this . current _line = null ;
this . next _line = new OutputLine ( this ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = false ;
// initialize
this . _ _add _outputline ( ) ;
}
Output . prototype . _ _add _outputline = function ( ) {
this . previous _line = this . current _line ;
this . current _line = this . next _line . clone _empty ( ) ;
this . _ _lines . push ( this . current _line ) ;
} ;
Output . prototype . get _line _number = function ( ) {
return this . _ _lines . length ;
} ;
Output . prototype . get _indent _string = function ( indent , column ) {
return this . _ _indent _cache . get _indent _string ( indent , column ) ;
} ;
Output . prototype . get _indent _size = function ( indent , column ) {
return this . _ _indent _cache . get _indent _size ( indent , column ) ;
} ;
Output . prototype . is _empty = function ( ) {
return ! this . previous _line && this . current _line . is _empty ( ) ;
} ;
Output . prototype . add _new _line = function ( force _newline ) {
// never newline at the start of file
// otherwise, newline only if we didn't just add one or we're forced
if ( this . is _empty ( ) ||
( ! force _newline && this . just _added _newline ( ) ) ) {
return false ;
}
// if raw output is enabled, don't print additional newlines,
// but still return True as though you had
if ( ! this . raw ) {
this . _ _add _outputline ( ) ;
}
return true ;
} ;
Output . prototype . get _code = function ( eol ) {
this . trim ( true ) ;
// handle some edge cases where the last tokens
// has text that ends with newline(s)
var last _item = this . current _line . pop ( ) ;
if ( last _item ) {
if ( last _item [ last _item . length - 1 ] === '\n' ) {
last _item = last _item . replace ( /\n+$/g , '' ) ;
}
this . current _line . push ( last _item ) ;
}
if ( this . _end _with _newline ) {
this . _ _add _outputline ( ) ;
}
var sweet _code = this . _ _lines . join ( '\n' ) ;
if ( eol !== '\n' ) {
sweet _code = sweet _code . replace ( /[\n]/g , eol ) ;
}
return sweet _code ;
} ;
Output . prototype . set _wrap _point = function ( ) {
this . current _line . _set _wrap _point ( ) ;
} ;
Output . prototype . set _indent = function ( indent , alignment ) {
indent = indent || 0 ;
alignment = alignment || 0 ;
// Next line stores alignment values
this . next _line . set _indent ( indent , alignment ) ;
// Never indent your first output indent at the start of the file
if ( this . _ _lines . length > 1 ) {
this . current _line . set _indent ( indent , alignment ) ;
return true ;
}
this . current _line . set _indent ( ) ;
return false ;
} ;
Output . prototype . add _raw _token = function ( token ) {
for ( var x = 0 ; x < token . newlines ; x ++ ) {
this . _ _add _outputline ( ) ;
}
this . current _line . set _indent ( - 1 ) ;
this . current _line . push ( token . whitespace _before ) ;
this . current _line . push ( token . text ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = false ;
} ;
Output . prototype . add _token = function ( printable _token ) {
this . _ _add _space _before _token ( ) ;
this . current _line . push ( printable _token ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = this . current _line . _allow _wrap ( ) ;
} ;
Output . prototype . _ _add _space _before _token = function ( ) {
if ( this . space _before _token && ! this . just _added _newline ( ) ) {
if ( ! this . non _breaking _space ) {
this . set _wrap _point ( ) ;
}
this . current _line . push ( ' ' ) ;
}
} ;
Output . prototype . remove _indent = function ( index ) {
var output _length = this . _ _lines . length ;
while ( index < output _length ) {
this . _ _lines [ index ] . _remove _indent ( ) ;
index ++ ;
}
this . current _line . _remove _wrap _indent ( ) ;
} ;
Output . prototype . trim = function ( eat _newlines ) {
eat _newlines = ( eat _newlines === undefined ) ? false : eat _newlines ;
this . current _line . trim ( ) ;
while ( eat _newlines && this . _ _lines . length > 1 &&
this . current _line . is _empty ( ) ) {
this . _ _lines . pop ( ) ;
this . current _line = this . _ _lines [ this . _ _lines . length - 1 ] ;
this . current _line . trim ( ) ;
}
this . previous _line = this . _ _lines . length > 1 ?
this . _ _lines [ this . _ _lines . length - 2 ] : null ;
} ;
Output . prototype . just _added _newline = function ( ) {
return this . current _line . is _empty ( ) ;
} ;
Output . prototype . just _added _blankline = function ( ) {
return this . is _empty ( ) ||
( this . current _line . is _empty ( ) && this . previous _line . is _empty ( ) ) ;
} ;
Output . prototype . ensure _empty _line _above = function ( starts _with , ends _with ) {
var index = this . _ _lines . length - 2 ;
while ( index >= 0 ) {
var potentialEmptyLine = this . _ _lines [ index ] ;
if ( potentialEmptyLine . is _empty ( ) ) {
break ;
} else if ( potentialEmptyLine . item ( 0 ) . indexOf ( starts _with ) !== 0 &&
potentialEmptyLine . item ( - 1 ) !== ends _with ) {
this . _ _lines . splice ( index + 1 , 0 , new OutputLine ( this ) ) ;
this . previous _line = this . _ _lines [ this . _ _lines . length - 2 ] ;
break ;
}
index -- ;
}
} ;
module . exports . Output = Output ;
/***/ } ) ,
/* 4 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Token ( type , text , newlines , whitespace _before ) {
this . type = type ;
this . text = text ;
// comments_before are
// comments that have a new line before them
// and may or may not have a newline after
// this is a set of comments before
this . comments _before = null ; /* inline comment*/
// this.comments_after = new TokenStream(); // no new line before and newline after
this . newlines = newlines || 0 ;
this . whitespace _before = whitespace _before || '' ;
this . parent = null ;
this . next = null ;
this . previous = null ;
this . opened = null ;
this . closed = null ;
this . directives = null ;
}
module . exports . Token = Token ;
/***/ } ) ,
/* 5 */
/***/ ( function ( _ _unused _webpack _module , exports ) {
/* jshint node: true, curly: false */
// Parts of this section of code is taken from acorn.
//
// Acorn was written by Marijn Haverbeke and released under an MIT
// license. The Unicode regexps (for identifiers and whitespace) were
// taken from [Esprima](http://esprima.org) by Ariya Hidayat.
//
// Git repositories for Acorn are available at
//
// http://marijnhaverbeke.nl/git/acorn
// https://github.com/marijnh/acorn.git
// ## Character categories
// acorn used char codes to squeeze the last bit of performance out
// Beautifier is okay without that, so we're using regex
// permit # (23), $ (36), and @ (64). @ is used in ES7 decorators.
// 65 through 91 are uppercase letters.
// permit _ (95).
// 97 through 123 are lowercase letters.
var baseASCIIidentifierStartChars = "\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a" ;
// inside an identifier @ is not allowed but 0-9 are.
var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a" ;
// Big ugly regular expressions that match characters in the
// whitespace, identifier, and identifier-start categories. These
// are only applied when a character is found to actually have a
// code point above 128.
var nonASCIIidentifierStartChars = " \ \ xaa \ \ xb5 \ \ xba \ \ xc0 - \ \ xd6 \ \ xd8 - \ \ xf6 \ \ xf8 - \ \u02c1 \ \u02c6 - \ \u02d1 \ \u02e0 - \ \u02e4 \ \u02ec \ \u02ee \ \u0370 - \ \u0374 \ \u0376 \ \u0377 \ \u037a - \ \u037d \ \u0386 \ \u0388 - \ \u038a \ \u038c \ \u038e - \ \u03a1 \ \u03a3 - \ \u03f5 \ \u03f7 - \ \u0481 \ \u048a - \ \u0527 \ \u0531 - \ \u0556 \ \u0559 \ \u0561 - \ \u0587 \ \u05d0 - \ \u05ea \ \u05f0 - \ \u05f2 \ \u0620 - \ \u064a \ \u066e \ \u066f \ \u0671 - \ \u06d3 \ \u06d5 \ \u06e5 \ \u06e6 \ \u06ee \ \u06ef \ \u06fa - \ \u06fc \ \u06ff \ \u0710 \ \u0712 - \ \u072f \ \u074d - \ \u07a5 \ \u07b1 \ \u07ca - \ \u07ea \ \u07f4 \ \u07f5 \ \u07fa \ \u0800 - \ \u0815 \ \u081a \ \u0824 \ \u0828 \ \u0840 - \ \u0858 \ \u08a0 \ \u08a2 - \ \u08ac \ \u0904 - \ \u0939 \ \u093d \ \u0950 \ \u0958 - \ \u0961 \ \u0971 - \ \u0977 \ \u0979 - \ \u097f \ \u0985 - \ \u098c \ \u098f \ \u0990 \ \u0993 - \ \u09a8 \ \u09aa - \ \u09b0 \ \u09b2 \ \u09b6 - \ \u09b9 \ \u09bd \ \u09ce \ \u09dc \ \u09dd \ \u09df - \ \u09e1 \ \u09f0 \ \u09f1 \ \u0a05 - \ \u0a0a \ \u0a0f \ \u0a10 \ \u0a13 - \ \u0a28 \ \u0a2a - \ \u0a30 \ \u0a32 \ \u0a33 \ \u0a35 \ \u0a36 \ \u0a38 \ \u0a39 \ \u0a59 - \ \u0a5c \ \u0a5e \ \u0a72 - \ \u0a74 \ \u0a85 - \ \u0a8d \ \u0a8f - \ \u0a91 \ \u0a93 - \ \u0aa8 \ \u0aaa - \ \u0ab0 \ \u0ab2 \ \u0ab3 \ \u0ab5 - \ \u0ab9 \ \u0abd \ \u0ad0 \ \u0ae0 \ \u0ae1 \ \u0b05 - \ \u0b0c \ \u0b0f \ \u0b10 \ \u0b13 - \ \u0b28 \ \u0b2a - \ \u0b30 \ \u0b32 \ \u0b33 \ \u0b35 - \ \u0b39 \ \u0b3d \ \u0b5c \ \u0b5d \ \u0b5f - \ \u0b61 \ \u0b71 \ \u0b83 \ \u0b85 - \ \u0b8a \ \u0b8e - \ \u0b90 \ \u0b92 - \ \u0b95 \ \u0b99 \ \u0b9a \ \u0b9c \ \u0b9e \ \u0b9f \ \u0ba3 \ \u0ba4 \ \u0ba8 - \ \u0baa \ \u0bae - \ \u0bb9 \ \u0bd0 \ \u0c05 - \ \u0c0c \ \u0c0e - \ \u0c10 \ \u0c12 - \ \u0c28 \ \u0c2a - \ \u0c33 \ \u0c35 - \ \u0c39 \ \u0c3d \ \u0c58 \ \u0c59 \ \u0c60 \ \u0c61 \ \u0c85 - \ \u0c8c \ \u0c8e - \ \u0c90 \ \u0c92 - \ \u0ca8 \ \u0caa - \ \u0cb3 \ \u0cb5 - \ \u0cb9 \ \u0cbd \ \u0cde \ \u0ce0 \ \u0ce1 \ \u0cf1 \ \u0cf2 \ \u0d05 - \ \u0d0c \ \u0d0e - \ \u0d10 \ \u0d12 - \ \u0d3a \ \u0d3d \ \u0d4e \ \u0d60 \ \u0d61 \ \u0d7a - \ \u0d7f \ \u0d85 - \ \u0d96 \ \u0d9a - \ \u0db1 \ \u0db3 - \ \u0dbb \ \u0dbd \ \u0dc0 - \ \u0dc6 \ \u0e01 - \ \u0e30 \ \u0e32 \ \u0e33 \ \u0e40 - \ \u0e46 \ \u0e81 \ \u0e82 \ \u0e84 \ \u0e87 \ \u0e88 \ \u0e8a \ \u0e8d \ \u0e94 - \ \u0e97 \ \u0e99 - \ \u0e9f \ \u0ea1 - \ \u0ea3 \ \u0ea5 \ \u0ea7 \ \u0eaa \ \u0eab \ \u0ead - \ \u0eb0 \ \u0eb2 \ \u0eb3 \ \u0ebd \ \u0ec0 - \ \u0ec4 \ \u0ec6 \ \u0edc - \ \u0edf \ \u0f00 \ \u0f40 - \ \u0f47 \ \u0f49 - \ \u0f6c \ \u0f88 - \ \u0f8c \ \u1000 - \ \u102a \ \u103f \ \u1050 - \ \u1055 \ \u105a - \ \u105d \ \u1061 \ \u1065 \ \u1066 \ \u106e - \ \u1070 \ \u1075 - \ \u1081 \ \u108e \ \u10a0 - \ \u10c5 \ \u10c7 \ \u10cd \ \u10d0 - \ \u10fa \ \u10fc - \ \u1248 \ \u124a - \ \u124d \ \u1250 - \ \u1256 \ \u1258 \ \u125a - \ \u125d \ \u1260 - \ \u1288 \ \u128a - \ \u128d \ \u1290 - \ \u12b0 \ \u12b2 - \ \u12b5 \ \u12b8 - \ \u12be \ \u12c0 \ \u12c2 - \ \u12c5 \ \u12c8 - \ \u12d6 \ \u12d8 - \ \u1310 \ \u1312 - \ \u1315 \ \u1318 - \ \u135a \ \u1380 - \ \u138f \ \u13a0 - \ \u13f4 \ \u1401 - \ \u166c \ \u166f - \ \u167f \ \u1681 - \ \u169a \ \u16a0 - \ \u16ea \ \u16ee - \ \u16f0 \ \u1700 - \ \u170c \ \u170e - \ \u1711 \ \u1720 - \ \u1731 \ \u1740 - \ \u1751 \ \u1760 - \ \u176c \ \u176e - \ \u1770 \ \u1780 - \ \u17b3 \ \u17d7 \ \u17dc \ \u1820 - \ \u1877 \ \u1880 - \ \u18a8 \ \u18aa \ \u18b0 - \ \u18f5 \ \u1900 - \ \u191c \ \u1950 - \ \u196d \ \u1970 - \ \u1974 \ \u1980 - \ \u19ab \ \u19c1 - \ \u19c7 \ \u1a00 - \ \u1a16 \ \u1a20 - \ \u1a54 \ \u1aa7 \ \u1b05 - \ \u1b33 \ \u1b45 - \ \u1b4b \ \u1b83 - \ \u1ba0 \ \u1bae \ \u1baf \ \u1bba - \ \u1be5 \ \u1c00 - \ \u1c23 \ \u1c4d - \ \u1c4f \ \u1c5a - \ \u1c7d \ \u1ce9 - \ \u1cec \ \u1cee - \ \u1cf1 \ \u1cf5 \ \u1cf6 \ \u1d00 - \ \u1dbf \ \u1e00 - \ \u1f15 \ \u1f18 - \ \u1f1d \ \u1f20 - \ \u1f45 \ \u1f48 - \ \u1f4d \ \u1f50 - \ \u1f57 \ \u1f59 \ \u1f5b \ \u1f5d \ \u1f5f - \ \u1f7d \ \u1f80 - \ \u1fb4 \ \u1fb6 - \ \u1fbc \ \u1fbe \ \u1fc2 - \ \u1fc4 \ \u1fc6 - \ \u1fcc \ \u1fd0 - \ \u1fd3 \ \u1fd6 - \ \u1fdb \ \u1fe0 - \ \u1fec \ \u1ff2 - \ \u1ff4 \ \u1ff6 - \ \u1ffc \ \u2071 \ \u207f \ \u2090 - \ \u209c \ \u2102 \ \u2107 \ \u210a - \ \u2113 \ \u2115 \ \u2119 - \ \u211d \ \u2124 \ \u2126 \ \u2128 \ \u212a - \ \u212d \ \u212f - \ \u2139 \ \u213c - \ \u213f \ \u2145 - \ \u2149 \ \u214e \ \u2160 - \ \u2188 \ \u2c00 - \ \u2c2e \ \u2c30 - \ \u2c5e \ \u2c60 - \ \u2ce4 \ \u2ceb - \ \u2cee \ \u2cf2 \ \u2cf3 \ \u2d00 - \ \u2d25 \ \u2d27 \ \u2d2d \ \u2d30 - \ \u2d67 \ \u2d6f \ \u2d80 - \ \u2d96 \ \u2da0 - \ \u2da6 \ \u2da8 - \ \u2dae \ \u2db0 - \ \u2db6 \ \u2db8 - \ \u2dbe \ \u2dc0 - \ \u2dc6 \ \u2dc8 - \ \u2dce \ \u2dd0 - \ \u2dd6 \ \u2dd8 - \ \u2dde \ \u2e2f \ \u3005 - \ \u3007 \ \u3021 - \ \u3029 \ \u3031 - \ \u3035 \ \u3038 - \ \u303c \ \u3041 - \ \u3096 \ \u309d - \ \u309f \ \u30a1 - \ \u30fa \ \u30fc - \ \u30ff \ \u3105 - \ \u312d \ \u3131 - \ \u318e \ \u31a0 - \ \u31ba \ \u31f0 - \ \u31ff \ \u3400 - \ \u4db5 \ \u4e00 - \ \u9fcc \ \ua000 - \ \ua48c \ \ua4d0 - \ \ua4fd \ \ua500 - \ \ua60c \ \ua610 - \ \ua61f \ \ua62a \ \ua62b \ \ua640 - \ \ua66e \ \ua67f - \ \ua697 \ \ua6a0 - \ \ua6ef \ \ua717 - \ \ua71f \ \ua722 - \ \ua788 \ \ua78b - \ \ua78e \ \ua790 - \ \ua793 \ \ua7a0 - \ \ua7aa \ \ua7f8 - \ \ua801 \ \ua803 - \ \ua805 \ \ua807 - \ \ua80a \ \ ua80
var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f" ;
//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])" ;
var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*" ;
exports . identifier = new RegExp ( identifierStart + identifierChars , 'g' ) ;
exports . identifierStart = new RegExp ( identifierStart ) ;
exports . identifierMatch = new RegExp ( "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+" ) ;
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/ ; // jshint ignore:line
// Whether a single character denotes a newline.
exports . newline = /[\n\r\u2028\u2029]/ ;
// Matches a whole line break (where CRLF is considered a single
// line break). Used to count lines.
// in javascript, these two differ
// in python they are the same, different methods are called on them
exports . lineBreak = new RegExp ( '\r\n|' + exports . newline . source ) ;
exports . allLineBreaks = new RegExp ( exports . lineBreak . source , 'g' ) ;
/***/ } ) ,
/* 6 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseOptions = ( _ _webpack _require _ _ ( 7 ) . Options ) ;
2022-01-21 08:28:41 +00:00
var validPositionValues = [ 'before-newline' , 'after-newline' , 'preserve-newline' ] ;
function Options ( options ) {
BaseOptions . call ( this , options , 'js' ) ;
// compatibility, re
var raw _brace _style = this . raw _options . brace _style || null ;
if ( raw _brace _style === "expand-strict" ) { //graceful handling of deprecated option
this . raw _options . brace _style = "expand" ;
} else if ( raw _brace _style === "collapse-preserve-inline" ) { //graceful handling of deprecated option
this . raw _options . brace _style = "collapse,preserve-inline" ;
} else if ( this . raw _options . braces _on _own _line !== undefined ) { //graceful handling of deprecated option
this . raw _options . brace _style = this . raw _options . braces _on _own _line ? "expand" : "collapse" ;
// } else if (!raw_brace_style) { //Nothing exists to set it
// raw_brace_style = "collapse";
}
//preserve-inline in delimited string will trigger brace_preserve_inline, everything
//else is considered a brace_style and the last one only will have an effect
var brace _style _split = this . _get _selection _list ( 'brace_style' , [ 'collapse' , 'expand' , 'end-expand' , 'none' , 'preserve-inline' ] ) ;
this . brace _preserve _inline = false ; //Defaults in case one or other was not specified in meta-option
this . brace _style = "collapse" ;
for ( var bs = 0 ; bs < brace _style _split . length ; bs ++ ) {
if ( brace _style _split [ bs ] === "preserve-inline" ) {
this . brace _preserve _inline = true ;
} else {
this . brace _style = brace _style _split [ bs ] ;
}
}
this . unindent _chained _methods = this . _get _boolean ( 'unindent_chained_methods' ) ;
this . break _chained _methods = this . _get _boolean ( 'break_chained_methods' ) ;
this . space _in _paren = this . _get _boolean ( 'space_in_paren' ) ;
this . space _in _empty _paren = this . _get _boolean ( 'space_in_empty_paren' ) ;
this . jslint _happy = this . _get _boolean ( 'jslint_happy' ) ;
this . space _after _anon _function = this . _get _boolean ( 'space_after_anon_function' ) ;
this . space _after _named _function = this . _get _boolean ( 'space_after_named_function' ) ;
this . keep _array _indentation = this . _get _boolean ( 'keep_array_indentation' ) ;
this . space _before _conditional = this . _get _boolean ( 'space_before_conditional' , true ) ;
this . unescape _strings = this . _get _boolean ( 'unescape_strings' ) ;
this . e4x = this . _get _boolean ( 'e4x' ) ;
this . comma _first = this . _get _boolean ( 'comma_first' ) ;
this . operator _position = this . _get _selection ( 'operator_position' , validPositionValues ) ;
// For testing of beautify preserve:start directive
this . test _output _raw = this . _get _boolean ( 'test_output_raw' ) ;
// force this._options.space_after_anon_function to true if this._options.jslint_happy
if ( this . jslint _happy ) {
this . space _after _anon _function = true ;
}
}
Options . prototype = new BaseOptions ( ) ;
module . exports . Options = Options ;
/***/ } ) ,
/* 7 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Options ( options , merge _child _field ) {
this . raw _options = _mergeOpts ( options , merge _child _field ) ;
// Support passing the source text back with no change
this . disabled = this . _get _boolean ( 'disabled' ) ;
this . eol = this . _get _characters ( 'eol' , 'auto' ) ;
this . end _with _newline = this . _get _boolean ( 'end_with_newline' ) ;
this . indent _size = this . _get _number ( 'indent_size' , 4 ) ;
this . indent _char = this . _get _characters ( 'indent_char' , ' ' ) ;
this . indent _level = this . _get _number ( 'indent_level' ) ;
this . preserve _newlines = this . _get _boolean ( 'preserve_newlines' , true ) ;
this . max _preserve _newlines = this . _get _number ( 'max_preserve_newlines' , 32786 ) ;
if ( ! this . preserve _newlines ) {
this . max _preserve _newlines = 0 ;
}
this . indent _with _tabs = this . _get _boolean ( 'indent_with_tabs' , this . indent _char === '\t' ) ;
if ( this . indent _with _tabs ) {
this . indent _char = '\t' ;
// indent_size behavior changed after 1.8.6
// It used to be that indent_size would be
// set to 1 for indent_with_tabs. That is no longer needed and
// actually doesn't make sense - why not use spaces? Further,
// that might produce unexpected behavior - tabs being used
// for single-column alignment. So, when indent_with_tabs is true
// and indent_size is 1, reset indent_size to 4.
if ( this . indent _size === 1 ) {
this . indent _size = 4 ;
}
}
// Backwards compat with 1.3.x
this . wrap _line _length = this . _get _number ( 'wrap_line_length' , this . _get _number ( 'max_char' ) ) ;
this . indent _empty _lines = this . _get _boolean ( 'indent_empty_lines' ) ;
// valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty']
// For now, 'auto' = all off for javascript, all on for html (and inline javascript).
// other values ignored
this . templating = this . _get _selection _list ( 'templating' , [ 'auto' , 'none' , 'django' , 'erb' , 'handlebars' , 'php' , 'smarty' ] , [ 'auto' ] ) ;
}
Options . prototype . _get _array = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = default _value || [ ] ;
if ( typeof option _value === 'object' ) {
if ( option _value !== null && typeof option _value . concat === 'function' ) {
result = option _value . concat ( ) ;
}
} else if ( typeof option _value === 'string' ) {
result = option _value . split ( /[^a-zA-Z0-9_\/\-]+/ ) ;
}
return result ;
} ;
Options . prototype . _get _boolean = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = option _value === undefined ? ! ! default _value : ! ! option _value ;
return result ;
} ;
Options . prototype . _get _characters = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = default _value || '' ;
if ( typeof option _value === 'string' ) {
result = option _value . replace ( /\\r/ , '\r' ) . replace ( /\\n/ , '\n' ) . replace ( /\\t/ , '\t' ) ;
}
return result ;
} ;
Options . prototype . _get _number = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
default _value = parseInt ( default _value , 10 ) ;
if ( isNaN ( default _value ) ) {
default _value = 0 ;
}
var result = parseInt ( option _value , 10 ) ;
if ( isNaN ( result ) ) {
result = default _value ;
}
return result ;
} ;
Options . prototype . _get _selection = function ( name , selection _list , default _value ) {
var result = this . _get _selection _list ( name , selection _list , default _value ) ;
if ( result . length !== 1 ) {
throw new Error (
"Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
selection _list + "\nYou passed in: '" + this . raw _options [ name ] + "'" ) ;
}
return result [ 0 ] ;
} ;
Options . prototype . _get _selection _list = function ( name , selection _list , default _value ) {
if ( ! selection _list || selection _list . length === 0 ) {
throw new Error ( "Selection list cannot be empty." ) ;
}
default _value = default _value || [ selection _list [ 0 ] ] ;
if ( ! this . _is _valid _selection ( default _value , selection _list ) ) {
throw new Error ( "Invalid Default Value!" ) ;
}
var result = this . _get _array ( name , default _value ) ;
if ( ! this . _is _valid _selection ( result , selection _list ) ) {
throw new Error (
"Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
selection _list + "\nYou passed in: '" + this . raw _options [ name ] + "'" ) ;
}
return result ;
} ;
Options . prototype . _is _valid _selection = function ( result , selection _list ) {
return result . length && selection _list . length &&
! result . some ( function ( item ) { return selection _list . indexOf ( item ) === - 1 ; } ) ;
} ;
// merges child options up with the parent options object
// Example: obj = {a: 1, b: {a: 2}}
// mergeOpts(obj, 'b')
//
// Returns: {a: 2}
function _mergeOpts ( allOptions , childFieldName ) {
var finalOpts = { } ;
allOptions = _normalizeOpts ( allOptions ) ;
var name ;
for ( name in allOptions ) {
if ( name !== childFieldName ) {
finalOpts [ name ] = allOptions [ name ] ;
}
}
//merge in the per type settings for the childFieldName
if ( childFieldName && allOptions [ childFieldName ] ) {
for ( name in allOptions [ childFieldName ] ) {
finalOpts [ name ] = allOptions [ childFieldName ] [ name ] ;
}
}
return finalOpts ;
}
function _normalizeOpts ( options ) {
var convertedOpts = { } ;
var key ;
for ( key in options ) {
var newKey = key . replace ( /-/g , "_" ) ;
convertedOpts [ newKey ] = options [ key ] ;
}
return convertedOpts ;
}
module . exports . Options = Options ;
module . exports . normalizeOpts = _normalizeOpts ;
module . exports . mergeOpts = _mergeOpts ;
/***/ } ) ,
/* 8 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var InputScanner = ( _ _webpack _require _ _ ( 9 ) . InputScanner ) ;
var BaseTokenizer = ( _ _webpack _require _ _ ( 10 ) . Tokenizer ) ;
var BASETOKEN = ( _ _webpack _require _ _ ( 10 ) . TOKEN ) ;
var Directives = ( _ _webpack _require _ _ ( 14 ) . Directives ) ;
2022-01-21 08:28:41 +00:00
var acorn = _ _webpack _require _ _ ( 5 ) ;
2022-04-07 13:41:52 +00:00
var Pattern = ( _ _webpack _require _ _ ( 13 ) . Pattern ) ;
var TemplatablePattern = ( _ _webpack _require _ _ ( 15 ) . TemplatablePattern ) ;
2022-01-21 08:28:41 +00:00
function in _array ( what , arr ) {
return arr . indexOf ( what ) !== - 1 ;
}
var TOKEN = {
START _EXPR : 'TK_START_EXPR' ,
END _EXPR : 'TK_END_EXPR' ,
START _BLOCK : 'TK_START_BLOCK' ,
END _BLOCK : 'TK_END_BLOCK' ,
WORD : 'TK_WORD' ,
RESERVED : 'TK_RESERVED' ,
SEMICOLON : 'TK_SEMICOLON' ,
STRING : 'TK_STRING' ,
EQUALS : 'TK_EQUALS' ,
OPERATOR : 'TK_OPERATOR' ,
COMMA : 'TK_COMMA' ,
BLOCK _COMMENT : 'TK_BLOCK_COMMENT' ,
COMMENT : 'TK_COMMENT' ,
DOT : 'TK_DOT' ,
UNKNOWN : 'TK_UNKNOWN' ,
START : BASETOKEN . START ,
RAW : BASETOKEN . RAW ,
EOF : BASETOKEN . EOF
} ;
var directives _core = new Directives ( /\/\*/ , /\*\// ) ;
var number _pattern = /0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/ ;
var digit = /[0-9]/ ;
// Dot "." must be distinguished from "..." and decimal
var dot _pattern = /[^\d\.]/ ;
var positionable _operators = (
2022-04-11 08:07:00 +00:00
">>> === !== &&= ??= ||= " +
2022-01-21 08:28:41 +00:00
"<< && >= ** != == <= >> || ?? |> " +
"< / - + > : & % ? ^ | *" ) . split ( ' ' ) ;
// IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
// Also, you must update possitionable operators separately from punct
var punct =
">>>= " +
2022-04-11 08:07:00 +00:00
"... >>= <<= === >>> !== **= &&= ??= ||= " +
2022-01-21 08:28:41 +00:00
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
"= ! ? > < : / ^ - + * & % ~ |" ;
punct = punct . replace ( /[-[\]{}()*+?.,\\^$|#]/g , "\\$&" ) ;
// ?. but not if followed by a number
punct = '\\?\\.(?!\\d) ' + punct ;
punct = punct . replace ( / /g , '|' ) ;
var punct _pattern = new RegExp ( punct ) ;
// words which should always start on new line.
var line _starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export' . split ( ',' ) ;
2022-07-11 11:25:19 +00:00
var reserved _words = line _starters . concat ( [ 'do' , 'in' , 'of' , 'else' , 'get' , 'set' , 'new' , 'catch' , 'finally' , 'typeof' , 'yield' , 'async' , 'await' , 'from' , 'as' , 'class' , 'extends' ] ) ;
2022-01-21 08:28:41 +00:00
var reserved _word _pattern = new RegExp ( '^(?:' + reserved _words . join ( '|' ) + ')$' ) ;
// var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
var in _html _comment ;
var Tokenizer = function ( input _string , options ) {
BaseTokenizer . call ( this , input _string , options ) ;
this . _patterns . whitespace = this . _patterns . whitespace . matching (
/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/ . source ,
/\u2028\u2029/ . source ) ;
var pattern _reader = new Pattern ( this . _input ) ;
var templatable = new TemplatablePattern ( this . _input )
. read _options ( this . _options ) ;
this . _ _patterns = {
template : templatable ,
identifier : templatable . starting _with ( acorn . identifier ) . matching ( acorn . identifierMatch ) ,
number : pattern _reader . matching ( number _pattern ) ,
punct : pattern _reader . matching ( punct _pattern ) ,
// comment ends just before nearest linefeed or end of file
comment : pattern _reader . starting _with ( /\/\// ) . until ( /[\n\r\u2028\u2029]/ ) ,
// /* ... */ comment ends with nearest */ or end of file
block _comment : pattern _reader . starting _with ( /\/\*/ ) . until _after ( /\*\// ) ,
html _comment _start : pattern _reader . matching ( /<!--/ ) ,
html _comment _end : pattern _reader . matching ( /-->/ ) ,
include : pattern _reader . starting _with ( /#include/ ) . until _after ( acorn . lineBreak ) ,
shebang : pattern _reader . starting _with ( /#!/ ) . until _after ( acorn . lineBreak ) ,
2022-04-07 13:41:52 +00:00
xml : pattern _reader . matching ( /[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/ ) ,
2022-01-21 08:28:41 +00:00
single _quote : templatable . until ( /['\\\n\r\u2028\u2029]/ ) ,
double _quote : templatable . until ( /["\\\n\r\u2028\u2029]/ ) ,
template _text : templatable . until ( /[`\\$]/ ) ,
template _expression : templatable . until ( /[`}\\]/ )
} ;
} ;
Tokenizer . prototype = new BaseTokenizer ( ) ;
Tokenizer . prototype . _is _comment = function ( current _token ) {
return current _token . type === TOKEN . COMMENT || current _token . type === TOKEN . BLOCK _COMMENT || current _token . type === TOKEN . UNKNOWN ;
} ;
Tokenizer . prototype . _is _opening = function ( current _token ) {
return current _token . type === TOKEN . START _BLOCK || current _token . type === TOKEN . START _EXPR ;
} ;
Tokenizer . prototype . _is _closing = function ( current _token , open _token ) {
return ( current _token . type === TOKEN . END _BLOCK || current _token . type === TOKEN . END _EXPR ) &&
( open _token && (
( current _token . text === ']' && open _token . text === '[' ) ||
( current _token . text === ')' && open _token . text === '(' ) ||
( current _token . text === '}' && open _token . text === '{' ) ) ) ;
} ;
Tokenizer . prototype . _reset = function ( ) {
in _html _comment = false ;
} ;
Tokenizer . prototype . _get _next _token = function ( previous _token , open _token ) { // jshint unused:false
var token = null ;
this . _readWhitespace ( ) ;
var c = this . _input . peek ( ) ;
if ( c === null ) {
return this . _create _token ( TOKEN . EOF , '' ) ;
}
token = token || this . _read _non _javascript ( c ) ;
token = token || this . _read _string ( c ) ;
2023-08-17 09:47:40 +00:00
token = token || this . _read _pair ( c , this . _input . peek ( 1 ) ) ; // Issue #2062 hack for record type '#{'
2022-01-21 08:28:41 +00:00
token = token || this . _read _word ( previous _token ) ;
token = token || this . _read _singles ( c ) ;
token = token || this . _read _comment ( c ) ;
token = token || this . _read _regexp ( c , previous _token ) ;
token = token || this . _read _xml ( c , previous _token ) ;
token = token || this . _read _punctuation ( ) ;
token = token || this . _create _token ( TOKEN . UNKNOWN , this . _input . next ( ) ) ;
return token ;
} ;
Tokenizer . prototype . _read _word = function ( previous _token ) {
var resulting _string ;
resulting _string = this . _ _patterns . identifier . read ( ) ;
if ( resulting _string !== '' ) {
resulting _string = resulting _string . replace ( acorn . allLineBreaks , '\n' ) ;
if ( ! ( previous _token . type === TOKEN . DOT ||
( previous _token . type === TOKEN . RESERVED && ( previous _token . text === 'set' || previous _token . text === 'get' ) ) ) &&
reserved _word _pattern . test ( resulting _string ) ) {
2022-07-11 11:25:19 +00:00
if ( ( resulting _string === 'in' || resulting _string === 'of' ) &&
( previous _token . type === TOKEN . WORD || previous _token . type === TOKEN . STRING ) ) { // hack for 'in' and 'of' operators
2022-01-21 08:28:41 +00:00
return this . _create _token ( TOKEN . OPERATOR , resulting _string ) ;
}
return this . _create _token ( TOKEN . RESERVED , resulting _string ) ;
}
return this . _create _token ( TOKEN . WORD , resulting _string ) ;
}
resulting _string = this . _ _patterns . number . read ( ) ;
if ( resulting _string !== '' ) {
return this . _create _token ( TOKEN . WORD , resulting _string ) ;
}
} ;
Tokenizer . prototype . _read _singles = function ( c ) {
var token = null ;
if ( c === '(' || c === '[' ) {
token = this . _create _token ( TOKEN . START _EXPR , c ) ;
} else if ( c === ')' || c === ']' ) {
token = this . _create _token ( TOKEN . END _EXPR , c ) ;
} else if ( c === '{' ) {
token = this . _create _token ( TOKEN . START _BLOCK , c ) ;
} else if ( c === '}' ) {
token = this . _create _token ( TOKEN . END _BLOCK , c ) ;
} else if ( c === ';' ) {
token = this . _create _token ( TOKEN . SEMICOLON , c ) ;
} else if ( c === '.' && dot _pattern . test ( this . _input . peek ( 1 ) ) ) {
token = this . _create _token ( TOKEN . DOT , c ) ;
} else if ( c === ',' ) {
token = this . _create _token ( TOKEN . COMMA , c ) ;
}
if ( token ) {
this . _input . next ( ) ;
}
return token ;
} ;
2023-08-17 09:47:40 +00:00
Tokenizer . prototype . _read _pair = function ( c , d ) {
var token = null ;
if ( c === '#' && d === '{' ) {
token = this . _create _token ( TOKEN . START _BLOCK , c + d ) ;
}
if ( token ) {
this . _input . next ( ) ;
this . _input . next ( ) ;
}
return token ;
} ;
2022-01-21 08:28:41 +00:00
Tokenizer . prototype . _read _punctuation = function ( ) {
var resulting _string = this . _ _patterns . punct . read ( ) ;
if ( resulting _string !== '' ) {
if ( resulting _string === '=' ) {
return this . _create _token ( TOKEN . EQUALS , resulting _string ) ;
} else if ( resulting _string === '?.' ) {
return this . _create _token ( TOKEN . DOT , resulting _string ) ;
} else {
return this . _create _token ( TOKEN . OPERATOR , resulting _string ) ;
}
}
} ;
Tokenizer . prototype . _read _non _javascript = function ( c ) {
var resulting _string = '' ;
if ( c === '#' ) {
if ( this . _is _first _token ( ) ) {
resulting _string = this . _ _patterns . shebang . read ( ) ;
if ( resulting _string ) {
return this . _create _token ( TOKEN . UNKNOWN , resulting _string . trim ( ) + '\n' ) ;
}
}
// handles extendscript #includes
resulting _string = this . _ _patterns . include . read ( ) ;
if ( resulting _string ) {
return this . _create _token ( TOKEN . UNKNOWN , resulting _string . trim ( ) + '\n' ) ;
}
c = this . _input . next ( ) ;
// Spidermonkey-specific sharp variables for circular references. Considered obsolete.
var sharp = '#' ;
if ( this . _input . hasNext ( ) && this . _input . testChar ( digit ) ) {
do {
c = this . _input . next ( ) ;
sharp += c ;
} while ( this . _input . hasNext ( ) && c !== '#' && c !== '=' ) ;
if ( c === '#' ) {
//
} else if ( this . _input . peek ( ) === '[' && this . _input . peek ( 1 ) === ']' ) {
sharp += '[]' ;
this . _input . next ( ) ;
this . _input . next ( ) ;
} else if ( this . _input . peek ( ) === '{' && this . _input . peek ( 1 ) === '}' ) {
sharp += '{}' ;
this . _input . next ( ) ;
this . _input . next ( ) ;
}
return this . _create _token ( TOKEN . WORD , sharp ) ;
}
this . _input . back ( ) ;
} else if ( c === '<' && this . _is _first _token ( ) ) {
resulting _string = this . _ _patterns . html _comment _start . read ( ) ;
if ( resulting _string ) {
while ( this . _input . hasNext ( ) && ! this . _input . testChar ( acorn . newline ) ) {
resulting _string += this . _input . next ( ) ;
}
in _html _comment = true ;
return this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
}
} else if ( in _html _comment && c === '-' ) {
resulting _string = this . _ _patterns . html _comment _end . read ( ) ;
if ( resulting _string ) {
in _html _comment = false ;
return this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
}
}
return null ;
} ;
Tokenizer . prototype . _read _comment = function ( c ) {
var token = null ;
if ( c === '/' ) {
var comment = '' ;
if ( this . _input . peek ( 1 ) === '*' ) {
// peek for comment /* ... */
comment = this . _ _patterns . block _comment . read ( ) ;
var directives = directives _core . get _directives ( comment ) ;
if ( directives && directives . ignore === 'start' ) {
comment += directives _core . readIgnored ( this . _input ) ;
}
comment = comment . replace ( acorn . allLineBreaks , '\n' ) ;
token = this . _create _token ( TOKEN . BLOCK _COMMENT , comment ) ;
token . directives = directives ;
} else if ( this . _input . peek ( 1 ) === '/' ) {
// peek for comment // ...
comment = this . _ _patterns . comment . read ( ) ;
token = this . _create _token ( TOKEN . COMMENT , comment ) ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _string = function ( c ) {
if ( c === '`' || c === "'" || c === '"' ) {
var resulting _string = this . _input . next ( ) ;
this . has _char _escapes = false ;
if ( c === '`' ) {
resulting _string += this . _read _string _recursive ( '`' , true , '${' ) ;
} else {
resulting _string += this . _read _string _recursive ( c ) ;
}
if ( this . has _char _escapes && this . _options . unescape _strings ) {
resulting _string = unescape _string ( resulting _string ) ;
}
if ( this . _input . peek ( ) === c ) {
resulting _string += this . _input . next ( ) ;
}
resulting _string = resulting _string . replace ( acorn . allLineBreaks , '\n' ) ;
return this . _create _token ( TOKEN . STRING , resulting _string ) ;
}
return null ;
} ;
Tokenizer . prototype . _allow _regexp _or _xml = function ( previous _token ) {
// regex and xml can only appear in specific locations during parsing
return ( previous _token . type === TOKEN . RESERVED && in _array ( previous _token . text , [ 'return' , 'case' , 'throw' , 'else' , 'do' , 'typeof' , 'yield' ] ) ) ||
( previous _token . type === TOKEN . END _EXPR && previous _token . text === ')' &&
previous _token . opened . previous . type === TOKEN . RESERVED && in _array ( previous _token . opened . previous . text , [ 'if' , 'while' , 'for' ] ) ) ||
( in _array ( previous _token . type , [ TOKEN . COMMENT , TOKEN . START _EXPR , TOKEN . START _BLOCK , TOKEN . START ,
TOKEN . END _BLOCK , TOKEN . OPERATOR , TOKEN . EQUALS , TOKEN . EOF , TOKEN . SEMICOLON , TOKEN . COMMA
] ) ) ;
} ;
Tokenizer . prototype . _read _regexp = function ( c , previous _token ) {
if ( c === '/' && this . _allow _regexp _or _xml ( previous _token ) ) {
// handle regexp
//
var resulting _string = this . _input . next ( ) ;
var esc = false ;
var in _char _class = false ;
while ( this . _input . hasNext ( ) &&
( ( esc || in _char _class || this . _input . peek ( ) !== c ) &&
! this . _input . testChar ( acorn . newline ) ) ) {
resulting _string += this . _input . peek ( ) ;
if ( ! esc ) {
esc = this . _input . peek ( ) === '\\' ;
if ( this . _input . peek ( ) === '[' ) {
in _char _class = true ;
} else if ( this . _input . peek ( ) === ']' ) {
in _char _class = false ;
}
} else {
esc = false ;
}
this . _input . next ( ) ;
}
if ( this . _input . peek ( ) === c ) {
resulting _string += this . _input . next ( ) ;
// regexps may have modifiers /regexp/MOD , so fetch those, too
// Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
resulting _string += this . _input . read ( acorn . identifier ) ;
}
return this . _create _token ( TOKEN . STRING , resulting _string ) ;
}
return null ;
} ;
Tokenizer . prototype . _read _xml = function ( c , previous _token ) {
if ( this . _options . e4x && c === "<" && this . _allow _regexp _or _xml ( previous _token ) ) {
var xmlStr = '' ;
var match = this . _ _patterns . xml . read _match ( ) ;
// handle e4x xml literals
//
if ( match ) {
// Trim root tag to attempt to
var rootTag = match [ 2 ] . replace ( /^{\s+/ , '{' ) . replace ( /\s+}$/ , '}' ) ;
var isCurlyRoot = rootTag . indexOf ( '{' ) === 0 ;
var depth = 0 ;
while ( match ) {
var isEndTag = ! ! match [ 1 ] ;
var tagName = match [ 2 ] ;
var isSingletonTag = ( ! ! match [ match . length - 1 ] ) || ( tagName . slice ( 0 , 8 ) === "![CDATA[" ) ;
if ( ! isSingletonTag &&
( tagName === rootTag || ( isCurlyRoot && tagName . replace ( /^{\s+/ , '{' ) . replace ( /\s+}$/ , '}' ) ) ) ) {
if ( isEndTag ) {
-- depth ;
} else {
++ depth ;
}
}
xmlStr += match [ 0 ] ;
if ( depth <= 0 ) {
break ;
}
match = this . _ _patterns . xml . read _match ( ) ;
}
// if we didn't close correctly, keep unformatted.
if ( ! match ) {
xmlStr += this . _input . match ( /[\s\S]*/g ) [ 0 ] ;
}
xmlStr = xmlStr . replace ( acorn . allLineBreaks , '\n' ) ;
return this . _create _token ( TOKEN . STRING , xmlStr ) ;
}
}
return null ;
} ;
function unescape _string ( s ) {
// You think that a regex would work for this
// return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
// return String.fromCharCode(parseInt(val, 16));
// })
// However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
var out = '' ,
escaped = 0 ;
var input _scan = new InputScanner ( s ) ;
var matched = null ;
while ( input _scan . hasNext ( ) ) {
// Keep any whitespace, non-slash characters
// also keep slash pairs.
matched = input _scan . match ( /([\s]|[^\\]|\\\\)+/g ) ;
if ( matched ) {
out += matched [ 0 ] ;
}
if ( input _scan . peek ( ) === '\\' ) {
input _scan . next ( ) ;
if ( input _scan . peek ( ) === 'x' ) {
matched = input _scan . match ( /x([0-9A-Fa-f]{2})/g ) ;
} else if ( input _scan . peek ( ) === 'u' ) {
matched = input _scan . match ( /u([0-9A-Fa-f]{4})/g ) ;
} else {
out += '\\' ;
if ( input _scan . hasNext ( ) ) {
out += input _scan . next ( ) ;
}
continue ;
}
// If there's some error decoding, return the original string
if ( ! matched ) {
return s ;
}
escaped = parseInt ( matched [ 1 ] , 16 ) ;
if ( escaped > 0x7e && escaped <= 0xff && matched [ 0 ] . indexOf ( 'x' ) === 0 ) {
// we bail out on \x7f..\xff,
// leaving whole string escaped,
// as it's probably completely binary
return s ;
} else if ( escaped >= 0x00 && escaped < 0x20 ) {
// leave 0x00...0x1f escaped
out += '\\' + matched [ 0 ] ;
continue ;
} else if ( escaped === 0x22 || escaped === 0x27 || escaped === 0x5c ) {
// single-quote, apostrophe, backslash - escape these
out += '\\' + String . fromCharCode ( escaped ) ;
} else {
out += String . fromCharCode ( escaped ) ;
}
}
}
return out ;
}
// handle string
//
Tokenizer . prototype . _read _string _recursive = function ( delimiter , allow _unescaped _newlines , start _sub ) {
var current _char ;
var pattern ;
if ( delimiter === '\'' ) {
pattern = this . _ _patterns . single _quote ;
} else if ( delimiter === '"' ) {
pattern = this . _ _patterns . double _quote ;
} else if ( delimiter === '`' ) {
pattern = this . _ _patterns . template _text ;
} else if ( delimiter === '}' ) {
pattern = this . _ _patterns . template _expression ;
}
var resulting _string = pattern . read ( ) ;
var next = '' ;
while ( this . _input . hasNext ( ) ) {
next = this . _input . next ( ) ;
if ( next === delimiter ||
( ! allow _unescaped _newlines && acorn . newline . test ( next ) ) ) {
this . _input . back ( ) ;
break ;
} else if ( next === '\\' && this . _input . hasNext ( ) ) {
current _char = this . _input . peek ( ) ;
if ( current _char === 'x' || current _char === 'u' ) {
this . has _char _escapes = true ;
} else if ( current _char === '\r' && this . _input . peek ( 1 ) === '\n' ) {
this . _input . next ( ) ;
}
next += this . _input . next ( ) ;
} else if ( start _sub ) {
if ( start _sub === '${' && next === '$' && this . _input . peek ( ) === '{' ) {
next += this . _input . next ( ) ;
}
if ( start _sub === next ) {
if ( delimiter === '`' ) {
next += this . _read _string _recursive ( '}' , allow _unescaped _newlines , '`' ) ;
} else {
next += this . _read _string _recursive ( '`' , allow _unescaped _newlines , '${' ) ;
}
if ( this . _input . hasNext ( ) ) {
next += this . _input . next ( ) ;
}
}
}
next += pattern . read ( ) ;
resulting _string += next ;
}
return resulting _string ;
} ;
module . exports . Tokenizer = Tokenizer ;
module . exports . TOKEN = TOKEN ;
module . exports . positionable _operators = positionable _operators . slice ( ) ;
module . exports . line _starters = line _starters . slice ( ) ;
/***/ } ) ,
/* 9 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
var regexp _has _sticky = RegExp . prototype . hasOwnProperty ( 'sticky' ) ;
function InputScanner ( input _string ) {
this . _ _input = input _string || '' ;
this . _ _input _length = this . _ _input . length ;
this . _ _position = 0 ;
}
InputScanner . prototype . restart = function ( ) {
this . _ _position = 0 ;
} ;
InputScanner . prototype . back = function ( ) {
if ( this . _ _position > 0 ) {
this . _ _position -= 1 ;
}
} ;
InputScanner . prototype . hasNext = function ( ) {
return this . _ _position < this . _ _input _length ;
} ;
InputScanner . prototype . next = function ( ) {
var val = null ;
if ( this . hasNext ( ) ) {
val = this . _ _input . charAt ( this . _ _position ) ;
this . _ _position += 1 ;
}
return val ;
} ;
InputScanner . prototype . peek = function ( index ) {
var val = null ;
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _input _length ) {
val = this . _ _input . charAt ( index ) ;
}
return val ;
} ;
// This is a JavaScript only helper function (not in python)
// Javascript doesn't have a match method
// and not all implementation support "sticky" flag.
// If they do not support sticky then both this.match() and this.test() method
// must get the match and check the index of the match.
// If sticky is supported and set, this method will use it.
// Otherwise it will check that global is set, and fall back to the slower method.
InputScanner . prototype . _ _match = function ( pattern , index ) {
pattern . lastIndex = index ;
var pattern _match = pattern . exec ( this . _ _input ) ;
if ( pattern _match && ! ( regexp _has _sticky && pattern . sticky ) ) {
if ( pattern _match . index !== index ) {
pattern _match = null ;
}
}
return pattern _match ;
} ;
InputScanner . prototype . test = function ( pattern , index ) {
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _input _length ) {
return ! ! this . _ _match ( pattern , index ) ;
} else {
return false ;
}
} ;
InputScanner . prototype . testChar = function ( pattern , index ) {
// test one character regex match
var val = this . peek ( index ) ;
pattern . lastIndex = 0 ;
return val !== null && pattern . test ( val ) ;
} ;
InputScanner . prototype . match = function ( pattern ) {
var pattern _match = this . _ _match ( pattern , this . _ _position ) ;
if ( pattern _match ) {
this . _ _position += pattern _match [ 0 ] . length ;
} else {
pattern _match = null ;
}
return pattern _match ;
} ;
InputScanner . prototype . read = function ( starting _pattern , until _pattern , until _after ) {
var val = '' ;
var match ;
if ( starting _pattern ) {
match = this . match ( starting _pattern ) ;
if ( match ) {
val += match [ 0 ] ;
}
}
if ( until _pattern && ( match || ! starting _pattern ) ) {
val += this . readUntil ( until _pattern , until _after ) ;
}
return val ;
} ;
InputScanner . prototype . readUntil = function ( pattern , until _after ) {
var val = '' ;
var match _index = this . _ _position ;
pattern . lastIndex = this . _ _position ;
var pattern _match = pattern . exec ( this . _ _input ) ;
if ( pattern _match ) {
match _index = pattern _match . index ;
if ( until _after ) {
match _index += pattern _match [ 0 ] . length ;
}
} else {
match _index = this . _ _input _length ;
}
val = this . _ _input . substring ( this . _ _position , match _index ) ;
this . _ _position = match _index ;
return val ;
} ;
InputScanner . prototype . readUntilAfter = function ( pattern ) {
return this . readUntil ( pattern , true ) ;
} ;
InputScanner . prototype . get _regexp = function ( pattern , match _from ) {
var result = null ;
var flags = 'g' ;
if ( match _from && regexp _has _sticky ) {
flags = 'y' ;
}
// strings are converted to regexp
if ( typeof pattern === "string" && pattern !== '' ) {
// result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
result = new RegExp ( pattern , flags ) ;
} else if ( pattern ) {
result = new RegExp ( pattern . source , flags ) ;
}
return result ;
} ;
InputScanner . prototype . get _literal _regexp = function ( literal _string ) {
return RegExp ( literal _string . replace ( /[-\/\\^$*+?.()|[\]{}]/g , '\\$&' ) ) ;
} ;
/* css beautifier legacy helpers */
InputScanner . prototype . peekUntilAfter = function ( pattern ) {
var start = this . _ _position ;
var val = this . readUntilAfter ( pattern ) ;
this . _ _position = start ;
return val ;
} ;
InputScanner . prototype . lookBack = function ( testVal ) {
var start = this . _ _position - 1 ;
return start >= testVal . length && this . _ _input . substring ( start - testVal . length , start )
. toLowerCase ( ) === testVal ;
} ;
module . exports . InputScanner = InputScanner ;
/***/ } ) ,
/* 10 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var InputScanner = ( _ _webpack _require _ _ ( 9 ) . InputScanner ) ;
var Token = ( _ _webpack _require _ _ ( 4 ) . Token ) ;
var TokenStream = ( _ _webpack _require _ _ ( 11 ) . TokenStream ) ;
var WhitespacePattern = ( _ _webpack _require _ _ ( 12 ) . WhitespacePattern ) ;
2022-01-21 08:28:41 +00:00
var TOKEN = {
START : 'TK_START' ,
RAW : 'TK_RAW' ,
EOF : 'TK_EOF'
} ;
var Tokenizer = function ( input _string , options ) {
this . _input = new InputScanner ( input _string ) ;
this . _options = options || { } ;
this . _ _tokens = null ;
this . _patterns = { } ;
this . _patterns . whitespace = new WhitespacePattern ( this . _input ) ;
} ;
Tokenizer . prototype . tokenize = function ( ) {
this . _input . restart ( ) ;
this . _ _tokens = new TokenStream ( ) ;
this . _reset ( ) ;
var current ;
var previous = new Token ( TOKEN . START , '' ) ;
var open _token = null ;
var open _stack = [ ] ;
var comments = new TokenStream ( ) ;
while ( previous . type !== TOKEN . EOF ) {
current = this . _get _next _token ( previous , open _token ) ;
while ( this . _is _comment ( current ) ) {
comments . add ( current ) ;
current = this . _get _next _token ( previous , open _token ) ;
}
if ( ! comments . isEmpty ( ) ) {
current . comments _before = comments ;
comments = new TokenStream ( ) ;
}
current . parent = open _token ;
if ( this . _is _opening ( current ) ) {
open _stack . push ( open _token ) ;
open _token = current ;
} else if ( open _token && this . _is _closing ( current , open _token ) ) {
current . opened = open _token ;
open _token . closed = current ;
open _token = open _stack . pop ( ) ;
current . parent = open _token ;
}
current . previous = previous ;
previous . next = current ;
this . _ _tokens . add ( current ) ;
previous = current ;
}
return this . _ _tokens ;
} ;
Tokenizer . prototype . _is _first _token = function ( ) {
return this . _ _tokens . isEmpty ( ) ;
} ;
Tokenizer . prototype . _reset = function ( ) { } ;
Tokenizer . prototype . _get _next _token = function ( previous _token , open _token ) { // jshint unused:false
this . _readWhitespace ( ) ;
var resulting _string = this . _input . read ( /.+/g ) ;
if ( resulting _string ) {
return this . _create _token ( TOKEN . RAW , resulting _string ) ;
} else {
return this . _create _token ( TOKEN . EOF , '' ) ;
}
} ;
Tokenizer . prototype . _is _comment = function ( current _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _is _opening = function ( current _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _is _closing = function ( current _token , open _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _create _token = function ( type , text ) {
var token = new Token ( type , text ,
this . _patterns . whitespace . newline _count ,
this . _patterns . whitespace . whitespace _before _token ) ;
return token ;
} ;
Tokenizer . prototype . _readWhitespace = function ( ) {
return this . _patterns . whitespace . read ( ) ;
} ;
module . exports . Tokenizer = Tokenizer ;
module . exports . TOKEN = TOKEN ;
/***/ } ) ,
/* 11 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function TokenStream ( parent _token ) {
// private
this . _ _tokens = [ ] ;
this . _ _tokens _length = this . _ _tokens . length ;
this . _ _position = 0 ;
this . _ _parent _token = parent _token ;
}
TokenStream . prototype . restart = function ( ) {
this . _ _position = 0 ;
} ;
TokenStream . prototype . isEmpty = function ( ) {
return this . _ _tokens _length === 0 ;
} ;
TokenStream . prototype . hasNext = function ( ) {
return this . _ _position < this . _ _tokens _length ;
} ;
TokenStream . prototype . next = function ( ) {
var val = null ;
if ( this . hasNext ( ) ) {
val = this . _ _tokens [ this . _ _position ] ;
this . _ _position += 1 ;
}
return val ;
} ;
TokenStream . prototype . peek = function ( index ) {
var val = null ;
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _tokens _length ) {
val = this . _ _tokens [ index ] ;
}
return val ;
} ;
TokenStream . prototype . add = function ( token ) {
if ( this . _ _parent _token ) {
token . parent = this . _ _parent _token ;
}
this . _ _tokens . push ( token ) ;
this . _ _tokens _length += 1 ;
} ;
module . exports . TokenStream = TokenStream ;
/***/ } ) ,
/* 12 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Pattern = ( _ _webpack _require _ _ ( 13 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
function WhitespacePattern ( input _scanner , parent ) {
Pattern . call ( this , input _scanner , parent ) ;
if ( parent ) {
this . _line _regexp = this . _input . get _regexp ( parent . _line _regexp ) ;
} else {
this . _ _set _whitespace _patterns ( '' , '' ) ;
}
this . newline _count = 0 ;
this . whitespace _before _token = '' ;
}
WhitespacePattern . prototype = new Pattern ( ) ;
WhitespacePattern . prototype . _ _set _whitespace _patterns = function ( whitespace _chars , newline _chars ) {
whitespace _chars += '\\t ' ;
newline _chars += '\\n\\r' ;
this . _match _pattern = this . _input . get _regexp (
'[' + whitespace _chars + newline _chars + ']+' , true ) ;
this . _newline _regexp = this . _input . get _regexp (
'\\r\\n|[' + newline _chars + ']' ) ;
} ;
WhitespacePattern . prototype . read = function ( ) {
this . newline _count = 0 ;
this . whitespace _before _token = '' ;
var resulting _string = this . _input . read ( this . _match _pattern ) ;
if ( resulting _string === ' ' ) {
this . whitespace _before _token = ' ' ;
} else if ( resulting _string ) {
var matches = this . _ _split ( this . _newline _regexp , resulting _string ) ;
this . newline _count = matches . length - 1 ;
this . whitespace _before _token = matches [ this . newline _count ] ;
}
return resulting _string ;
} ;
WhitespacePattern . prototype . matching = function ( whitespace _chars , newline _chars ) {
var result = this . _create ( ) ;
result . _ _set _whitespace _patterns ( whitespace _chars , newline _chars ) ;
result . _update ( ) ;
return result ;
} ;
WhitespacePattern . prototype . _create = function ( ) {
return new WhitespacePattern ( this . _input , this ) ;
} ;
WhitespacePattern . prototype . _ _split = function ( regexp , input _string ) {
regexp . lastIndex = 0 ;
var start _index = 0 ;
var result = [ ] ;
var next _match = regexp . exec ( input _string ) ;
while ( next _match ) {
result . push ( input _string . substring ( start _index , next _match . index ) ) ;
start _index = next _match . index + next _match [ 0 ] . length ;
next _match = regexp . exec ( input _string ) ;
}
if ( start _index < input _string . length ) {
result . push ( input _string . substring ( start _index , input _string . length ) ) ;
} else {
result . push ( '' ) ;
}
return result ;
} ;
module . exports . WhitespacePattern = WhitespacePattern ;
/***/ } ) ,
/* 13 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Pattern ( input _scanner , parent ) {
this . _input = input _scanner ;
this . _starting _pattern = null ;
this . _match _pattern = null ;
this . _until _pattern = null ;
this . _until _after = false ;
if ( parent ) {
this . _starting _pattern = this . _input . get _regexp ( parent . _starting _pattern , true ) ;
this . _match _pattern = this . _input . get _regexp ( parent . _match _pattern , true ) ;
this . _until _pattern = this . _input . get _regexp ( parent . _until _pattern ) ;
this . _until _after = parent . _until _after ;
}
}
Pattern . prototype . read = function ( ) {
var result = this . _input . read ( this . _starting _pattern ) ;
if ( ! this . _starting _pattern || result ) {
result += this . _input . read ( this . _match _pattern , this . _until _pattern , this . _until _after ) ;
}
return result ;
} ;
Pattern . prototype . read _match = function ( ) {
return this . _input . match ( this . _match _pattern ) ;
} ;
Pattern . prototype . until _after = function ( pattern ) {
var result = this . _create ( ) ;
result . _until _after = true ;
result . _until _pattern = this . _input . get _regexp ( pattern ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . until = function ( pattern ) {
var result = this . _create ( ) ;
result . _until _after = false ;
result . _until _pattern = this . _input . get _regexp ( pattern ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . starting _with = function ( pattern ) {
var result = this . _create ( ) ;
result . _starting _pattern = this . _input . get _regexp ( pattern , true ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . matching = function ( pattern ) {
var result = this . _create ( ) ;
result . _match _pattern = this . _input . get _regexp ( pattern , true ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . _create = function ( ) {
return new Pattern ( this . _input , this ) ;
} ;
Pattern . prototype . _update = function ( ) { } ;
module . exports . Pattern = Pattern ;
/***/ } ) ,
/* 14 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Directives ( start _block _pattern , end _block _pattern ) {
start _block _pattern = typeof start _block _pattern === 'string' ? start _block _pattern : start _block _pattern . source ;
end _block _pattern = typeof end _block _pattern === 'string' ? end _block _pattern : end _block _pattern . source ;
this . _ _directives _block _pattern = new RegExp ( start _block _pattern + / beautify( \w+[:]\w+)+ / . source + end _block _pattern , 'g' ) ;
this . _ _directive _pattern = / (\w+)[:](\w+)/g ;
this . _ _directives _end _ignore _pattern = new RegExp ( start _block _pattern + /\sbeautify\signore:end\s/ . source + end _block _pattern , 'g' ) ;
}
Directives . prototype . get _directives = function ( text ) {
if ( ! text . match ( this . _ _directives _block _pattern ) ) {
return null ;
}
var directives = { } ;
this . _ _directive _pattern . lastIndex = 0 ;
var directive _match = this . _ _directive _pattern . exec ( text ) ;
while ( directive _match ) {
directives [ directive _match [ 1 ] ] = directive _match [ 2 ] ;
directive _match = this . _ _directive _pattern . exec ( text ) ;
}
return directives ;
} ;
Directives . prototype . readIgnored = function ( input ) {
return input . readUntilAfter ( this . _ _directives _end _ignore _pattern ) ;
} ;
module . exports . Directives = Directives ;
/***/ } ) ,
/* 15 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Pattern = ( _ _webpack _require _ _ ( 13 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
var template _names = {
django : false ,
erb : false ,
handlebars : false ,
php : false ,
smarty : false
} ;
// This lets templates appear anywhere we would do a readUntil
// The cost is higher but it is pay to play.
function TemplatablePattern ( input _scanner , parent ) {
Pattern . call ( this , input _scanner , parent ) ;
this . _ _template _pattern = null ;
this . _disabled = Object . assign ( { } , template _names ) ;
this . _excluded = Object . assign ( { } , template _names ) ;
if ( parent ) {
this . _ _template _pattern = this . _input . get _regexp ( parent . _ _template _pattern ) ;
this . _excluded = Object . assign ( this . _excluded , parent . _excluded ) ;
this . _disabled = Object . assign ( this . _disabled , parent . _disabled ) ;
}
var pattern = new Pattern ( input _scanner ) ;
this . _ _patterns = {
handlebars _comment : pattern . starting _with ( /{{!--/ ) . until _after ( /--}}/ ) ,
handlebars _unescaped : pattern . starting _with ( /{{{/ ) . until _after ( /}}}/ ) ,
handlebars : pattern . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
php : pattern . starting _with ( /<\?(?:[= ]|php)/ ) . until _after ( /\?>/ ) ,
erb : pattern . starting _with ( /<%[^%]/ ) . until _after ( /[^%]%>/ ) ,
// django coflicts with handlebars a bit.
django : pattern . starting _with ( /{%/ ) . until _after ( /%}/ ) ,
django _value : pattern . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
django _comment : pattern . starting _with ( /{#/ ) . until _after ( /#}/ ) ,
smarty : pattern . starting _with ( /{(?=[^}{\s\n])/ ) . until _after ( /[^\s\n]}/ ) ,
smarty _comment : pattern . starting _with ( /{\*/ ) . until _after ( /\*}/ ) ,
smarty _literal : pattern . starting _with ( /{literal}/ ) . until _after ( /{\/literal}/ )
} ;
}
TemplatablePattern . prototype = new Pattern ( ) ;
TemplatablePattern . prototype . _create = function ( ) {
return new TemplatablePattern ( this . _input , this ) ;
} ;
TemplatablePattern . prototype . _update = function ( ) {
this . _ _set _templated _pattern ( ) ;
} ;
TemplatablePattern . prototype . disable = function ( language ) {
var result = this . _create ( ) ;
result . _disabled [ language ] = true ;
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . read _options = function ( options ) {
var result = this . _create ( ) ;
for ( var language in template _names ) {
result . _disabled [ language ] = options . templating . indexOf ( language ) === - 1 ;
}
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . exclude = function ( language ) {
var result = this . _create ( ) ;
result . _excluded [ language ] = true ;
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . read = function ( ) {
var result = '' ;
if ( this . _match _pattern ) {
result = this . _input . read ( this . _starting _pattern ) ;
} else {
result = this . _input . read ( this . _starting _pattern , this . _ _template _pattern ) ;
}
var next = this . _read _template ( ) ;
while ( next ) {
if ( this . _match _pattern ) {
next += this . _input . read ( this . _match _pattern ) ;
} else {
next += this . _input . readUntil ( this . _ _template _pattern ) ;
}
result += next ;
next = this . _read _template ( ) ;
}
if ( this . _until _after ) {
result += this . _input . readUntilAfter ( this . _until _pattern ) ;
}
return result ;
} ;
TemplatablePattern . prototype . _ _set _templated _pattern = function ( ) {
var items = [ ] ;
if ( ! this . _disabled . php ) {
items . push ( this . _ _patterns . php . _starting _pattern . source ) ;
}
if ( ! this . _disabled . handlebars ) {
items . push ( this . _ _patterns . handlebars . _starting _pattern . source ) ;
}
if ( ! this . _disabled . erb ) {
items . push ( this . _ _patterns . erb . _starting _pattern . source ) ;
}
if ( ! this . _disabled . django ) {
items . push ( this . _ _patterns . django . _starting _pattern . source ) ;
// The starting pattern for django is more complex because it has different
// patterns for value, comment, and other sections
items . push ( this . _ _patterns . django _value . _starting _pattern . source ) ;
items . push ( this . _ _patterns . django _comment . _starting _pattern . source ) ;
}
if ( ! this . _disabled . smarty ) {
items . push ( this . _ _patterns . smarty . _starting _pattern . source ) ;
}
if ( this . _until _pattern ) {
items . push ( this . _until _pattern . source ) ;
}
this . _ _template _pattern = this . _input . get _regexp ( '(?:' + items . join ( '|' ) + ')' ) ;
} ;
TemplatablePattern . prototype . _read _template = function ( ) {
var resulting _string = '' ;
var c = this . _input . peek ( ) ;
if ( c === '<' ) {
var peek1 = this . _input . peek ( 1 ) ;
//if we're in a comment, do something special
// We treat all comments as literals, even more than preformatted tags
// we just look for the appropriate close tag
if ( ! this . _disabled . php && ! this . _excluded . php && peek1 === '?' ) {
resulting _string = resulting _string ||
this . _ _patterns . php . read ( ) ;
}
if ( ! this . _disabled . erb && ! this . _excluded . erb && peek1 === '%' ) {
resulting _string = resulting _string ||
this . _ _patterns . erb . read ( ) ;
}
} else if ( c === '{' ) {
if ( ! this . _disabled . handlebars && ! this . _excluded . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . handlebars _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . handlebars _unescaped . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . handlebars . read ( ) ;
}
if ( ! this . _disabled . django ) {
// django coflicts with handlebars a bit.
if ( ! this . _excluded . django && ! this . _excluded . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . django _value . read ( ) ;
}
if ( ! this . _excluded . django ) {
resulting _string = resulting _string ||
this . _ _patterns . django _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . django . read ( ) ;
}
}
if ( ! this . _disabled . smarty ) {
// smarty cannot be enabled with django or handlebars enabled
if ( this . _disabled . django && this . _disabled . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . smarty _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . smarty _literal . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . smarty . read ( ) ;
}
}
}
return resulting _string ;
} ;
module . exports . TemplatablePattern = TemplatablePattern ;
/***/ } ) ,
/* 16 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Beautifier = ( _ _webpack _require _ _ ( 17 ) . Beautifier ) ,
Options = ( _ _webpack _require _ _ ( 18 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function css _beautify ( source _text , options ) {
var beautifier = new Beautifier ( source _text , options ) ;
return beautifier . beautify ( ) ;
}
module . exports = css _beautify ;
module . exports . defaultOptions = function ( ) {
return new Options ( ) ;
} ;
/***/ } ) ,
/* 17 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Options = ( _ _webpack _require _ _ ( 18 ) . Options ) ;
var Output = ( _ _webpack _require _ _ ( 3 ) . Output ) ;
var InputScanner = ( _ _webpack _require _ _ ( 9 ) . InputScanner ) ;
var Directives = ( _ _webpack _require _ _ ( 14 ) . Directives ) ;
2022-01-21 08:28:41 +00:00
var directives _core = new Directives ( /\/\*/ , /\*\// ) ;
var lineBreak = /\r\n|[\r\n]/ ;
var allLineBreaks = /\r\n|[\r\n]/g ;
// tokenizer
var whitespaceChar = /\s/ ;
var whitespacePattern = /(?:\s|\n)+/g ;
var block _comment _pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g ;
var comment _pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g ;
function Beautifier ( source _text , options ) {
this . _source _text = source _text || '' ;
// Allow the setting of language/file-type specific options
// with inheritance of overall settings
this . _options = new Options ( options ) ;
this . _ch = null ;
this . _input = null ;
// https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
this . NESTED _AT _RULE = {
2023-08-17 09:47:40 +00:00
"page" : true ,
"font-face" : true ,
"keyframes" : true ,
2022-01-21 08:28:41 +00:00
// also in CONDITIONAL_GROUP_RULE below
2023-08-17 09:47:40 +00:00
"media" : true ,
"supports" : true ,
"document" : true
2022-01-21 08:28:41 +00:00
} ;
this . CONDITIONAL _GROUP _RULE = {
2023-08-17 09:47:40 +00:00
"media" : true ,
"supports" : true ,
"document" : true
2022-01-21 08:28:41 +00:00
} ;
2022-04-11 08:07:00 +00:00
this . NON _SEMICOLON _NEWLINE _PROPERTY = [
2022-07-11 11:25:19 +00:00
"grid-template-areas" ,
2022-04-11 08:07:00 +00:00
"grid-template"
] ;
2022-01-21 08:28:41 +00:00
}
Beautifier . prototype . eatString = function ( endChars ) {
var result = '' ;
this . _ch = this . _input . next ( ) ;
while ( this . _ch ) {
result += this . _ch ;
if ( this . _ch === "\\" ) {
result += this . _input . next ( ) ;
} else if ( endChars . indexOf ( this . _ch ) !== - 1 || this . _ch === "\n" ) {
break ;
}
this . _ch = this . _input . next ( ) ;
}
return result ;
} ;
// Skips any white space in the source text from the current position.
// When allowAtLeastOneNewLine is true, will output new lines for each
// newline character found; if the user has preserve_newlines off, only
// the first newline will be output
Beautifier . prototype . eatWhitespace = function ( allowAtLeastOneNewLine ) {
var result = whitespaceChar . test ( this . _input . peek ( ) ) ;
var newline _count = 0 ;
while ( whitespaceChar . test ( this . _input . peek ( ) ) ) {
this . _ch = this . _input . next ( ) ;
if ( allowAtLeastOneNewLine && this . _ch === '\n' ) {
if ( newline _count === 0 || newline _count < this . _options . max _preserve _newlines ) {
newline _count ++ ;
this . _output . add _new _line ( true ) ;
}
}
}
return result ;
} ;
// Nested pseudo-class if we are insideRule
// and the next special character found opens
// a new block
Beautifier . prototype . foundNestedPseudoClass = function ( ) {
var openParen = 0 ;
var i = 1 ;
var ch = this . _input . peek ( i ) ;
while ( ch ) {
if ( ch === "{" ) {
return true ;
} else if ( ch === '(' ) {
// pseudoclasses can contain ()
openParen += 1 ;
} else if ( ch === ')' ) {
if ( openParen === 0 ) {
return false ;
}
openParen -= 1 ;
} else if ( ch === ";" || ch === "}" ) {
return false ;
}
i ++ ;
ch = this . _input . peek ( i ) ;
}
return false ;
} ;
Beautifier . prototype . print _string = function ( output _string ) {
this . _output . set _indent ( this . _indentLevel ) ;
this . _output . non _breaking _space = true ;
this . _output . add _token ( output _string ) ;
} ;
Beautifier . prototype . preserveSingleSpace = function ( isAfterSpace ) {
if ( isAfterSpace ) {
this . _output . space _before _token = true ;
}
} ;
Beautifier . prototype . indent = function ( ) {
this . _indentLevel ++ ;
} ;
Beautifier . prototype . outdent = function ( ) {
if ( this . _indentLevel > 0 ) {
this . _indentLevel -- ;
}
} ;
/*_____________________--------------------_____________________*/
Beautifier . prototype . beautify = function ( ) {
if ( this . _options . disabled ) {
return this . _source _text ;
}
var source _text = this . _source _text ;
var eol = this . _options . eol ;
if ( eol === 'auto' ) {
eol = '\n' ;
if ( source _text && lineBreak . test ( source _text || '' ) ) {
eol = source _text . match ( lineBreak ) [ 0 ] ;
}
}
// HACK: newline parsing inconsistent. This brute force normalizes the this._input.
source _text = source _text . replace ( allLineBreaks , '\n' ) ;
// reset
var baseIndentString = source _text . match ( /^[\t ]*/ ) [ 0 ] ;
this . _output = new Output ( this . _options , baseIndentString ) ;
this . _input = new InputScanner ( source _text ) ;
this . _indentLevel = 0 ;
this . _nestedLevel = 0 ;
this . _ch = null ;
var parenLevel = 0 ;
var insideRule = false ;
// This is the value side of a property value pair (blue in the following ex)
// label { content: blue }
var insidePropertyValue = false ;
var enteringConditionalGroup = false ;
2023-08-17 09:47:40 +00:00
var insideNonNestedAtRule = false ;
2022-04-11 08:07:00 +00:00
var insideScssMap = false ;
2022-01-21 08:28:41 +00:00
var topCharacter = this . _ch ;
2022-04-11 08:07:00 +00:00
var insideNonSemiColonValues = false ;
2022-01-21 08:28:41 +00:00
var whitespace ;
var isAfterSpace ;
var previous _ch ;
while ( true ) {
whitespace = this . _input . read ( whitespacePattern ) ;
isAfterSpace = whitespace !== '' ;
previous _ch = topCharacter ;
this . _ch = this . _input . next ( ) ;
if ( this . _ch === '\\' && this . _input . hasNext ( ) ) {
this . _ch += this . _input . next ( ) ;
}
topCharacter = this . _ch ;
if ( ! this . _ch ) {
break ;
} else if ( this . _ch === '/' && this . _input . peek ( ) === '*' ) {
// /* css comment */
// Always start block comments on a new line.
// This handles scenarios where a block comment immediately
// follows a property definition on the same line or where
// minified code is being beautified.
this . _output . add _new _line ( ) ;
this . _input . back ( ) ;
var comment = this . _input . read ( block _comment _pattern ) ;
// Handle ignore directive
var directives = directives _core . get _directives ( comment ) ;
if ( directives && directives . ignore === 'start' ) {
comment += directives _core . readIgnored ( this . _input ) ;
}
this . print _string ( comment ) ;
// Ensures any new lines following the comment are preserved
this . eatWhitespace ( true ) ;
// Block comments are followed by a new line so they don't
// share a line with other properties
this . _output . add _new _line ( ) ;
} else if ( this . _ch === '/' && this . _input . peek ( ) === '/' ) {
// // single line comment
// Preserves the space before a comment
// on the same line as a rule
this . _output . space _before _token = true ;
this . _input . back ( ) ;
this . print _string ( this . _input . read ( comment _pattern ) ) ;
// Ensures any new lines following the comment are preserved
this . eatWhitespace ( true ) ;
2023-08-17 09:47:40 +00:00
} else if ( this . _ch === '$' ) {
this . preserveSingleSpace ( isAfterSpace ) ;
this . print _string ( this . _ch ) ;
// strip trailing space, if present, for hash property checks
var variable = this . _input . peekUntilAfter ( /[: ,;{}()[\]\/='"]/g ) ;
if ( variable . match ( /[ :]$/ ) ) {
// we have a variable or pseudo-class, add it and insert one space before continuing
variable = this . eatString ( ": " ) . replace ( /\s$/ , '' ) ;
this . print _string ( variable ) ;
this . _output . space _before _token = true ;
}
variable = variable . replace ( /\s$/ , '' ) ;
// might be sass variable
if ( parenLevel === 0 && variable . indexOf ( ':' ) !== - 1 ) {
insidePropertyValue = true ;
this . indent ( ) ;
}
} else if ( this . _ch === '@' ) {
2022-01-21 08:28:41 +00:00
this . preserveSingleSpace ( isAfterSpace ) ;
2023-08-17 09:47:40 +00:00
// deal with less property mixins @{...}
2022-01-21 08:28:41 +00:00
if ( this . _input . peek ( ) === '{' ) {
this . print _string ( this . _ch + this . eatString ( '}' ) ) ;
} else {
this . print _string ( this . _ch ) ;
// strip trailing space, if present, for hash property checks
var variableOrRule = this . _input . peekUntilAfter ( /[: ,;{}()[\]\/='"]/g ) ;
if ( variableOrRule . match ( /[ :]$/ ) ) {
// we have a variable or pseudo-class, add it and insert one space before continuing
variableOrRule = this . eatString ( ": " ) . replace ( /\s$/ , '' ) ;
this . print _string ( variableOrRule ) ;
this . _output . space _before _token = true ;
}
variableOrRule = variableOrRule . replace ( /\s$/ , '' ) ;
2023-08-17 09:47:40 +00:00
// might be less variable
if ( parenLevel === 0 && variableOrRule . indexOf ( ':' ) !== - 1 ) {
insidePropertyValue = true ;
this . indent ( ) ;
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
// might be a nesting at-rule
} else if ( variableOrRule in this . NESTED _AT _RULE ) {
2022-01-21 08:28:41 +00:00
this . _nestedLevel += 1 ;
if ( variableOrRule in this . CONDITIONAL _GROUP _RULE ) {
enteringConditionalGroup = true ;
}
2023-08-17 09:47:40 +00:00
// might be a non-nested at-rule
} else if ( parenLevel === 0 && ! insidePropertyValue ) {
insideNonNestedAtRule = true ;
2022-01-21 08:28:41 +00:00
}
}
} else if ( this . _ch === '#' && this . _input . peek ( ) === '{' ) {
this . preserveSingleSpace ( isAfterSpace ) ;
this . print _string ( this . _ch + this . eatString ( '}' ) ) ;
} else if ( this . _ch === '{' ) {
if ( insidePropertyValue ) {
insidePropertyValue = false ;
this . outdent ( ) ;
}
2023-08-17 09:47:40 +00:00
// non nested at rule becomes nested
insideNonNestedAtRule = false ;
2022-01-21 08:28:41 +00:00
// when entering conditional groups, only rulesets are allowed
if ( enteringConditionalGroup ) {
enteringConditionalGroup = false ;
insideRule = ( this . _indentLevel >= this . _nestedLevel ) ;
} else {
// otherwise, declarations are also allowed
insideRule = ( this . _indentLevel >= this . _nestedLevel - 1 ) ;
}
if ( this . _options . newline _between _rules && insideRule ) {
if ( this . _output . previous _line && this . _output . previous _line . item ( - 1 ) !== '{' ) {
this . _output . ensure _empty _line _above ( '/' , ',' ) ;
}
}
this . _output . space _before _token = true ;
// The difference in print_string and indent order is necessary to indent the '{' correctly
if ( this . _options . brace _style === 'expand' ) {
this . _output . add _new _line ( ) ;
this . print _string ( this . _ch ) ;
this . indent ( ) ;
this . _output . set _indent ( this . _indentLevel ) ;
} else {
2022-04-11 08:07:00 +00:00
// inside mixin and first param is object
if ( previous _ch === '(' ) {
this . _output . space _before _token = false ;
} else if ( previous _ch !== ',' ) {
this . indent ( ) ;
}
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
}
this . eatWhitespace ( true ) ;
this . _output . add _new _line ( ) ;
} else if ( this . _ch === '}' ) {
this . outdent ( ) ;
this . _output . add _new _line ( ) ;
if ( previous _ch === '{' ) {
this . _output . trim ( true ) ;
}
2023-08-17 09:47:40 +00:00
2022-01-21 08:28:41 +00:00
if ( insidePropertyValue ) {
this . outdent ( ) ;
insidePropertyValue = false ;
}
this . print _string ( this . _ch ) ;
insideRule = false ;
if ( this . _nestedLevel ) {
this . _nestedLevel -- ;
}
this . eatWhitespace ( true ) ;
this . _output . add _new _line ( ) ;
if ( this . _options . newline _between _rules && ! this . _output . just _added _blankline ( ) ) {
if ( this . _input . peek ( ) !== '}' ) {
this . _output . add _new _line ( true ) ;
}
}
2022-04-11 08:07:00 +00:00
if ( this . _input . peek ( ) === ')' ) {
this . _output . trim ( true ) ;
if ( this . _options . brace _style === "expand" ) {
this . _output . add _new _line ( true ) ;
}
}
2022-01-21 08:28:41 +00:00
} else if ( this . _ch === ":" ) {
2022-04-11 08:07:00 +00:00
for ( var i = 0 ; i < this . NON _SEMICOLON _NEWLINE _PROPERTY . length ; i ++ ) {
if ( this . _input . lookBack ( this . NON _SEMICOLON _NEWLINE _PROPERTY [ i ] ) ) {
insideNonSemiColonValues = true ;
break ;
}
}
2023-08-17 09:47:40 +00:00
if ( ( insideRule || enteringConditionalGroup ) && ! ( this . _input . lookBack ( "&" ) || this . foundNestedPseudoClass ( ) ) && ! this . _input . lookBack ( "(" ) && ! insideNonNestedAtRule && parenLevel === 0 ) {
2022-01-21 08:28:41 +00:00
// 'property: value' delimiter
// which could be in a conditional group query
2023-08-17 09:47:40 +00:00
2022-01-21 08:28:41 +00:00
this . print _string ( ':' ) ;
if ( ! insidePropertyValue ) {
insidePropertyValue = true ;
this . _output . space _before _token = true ;
this . eatWhitespace ( true ) ;
this . indent ( ) ;
}
} else {
// sass/less parent reference don't use a space
// sass nested pseudo-class don't use a space
// preserve space before pseudoclasses/pseudoelements, as it means "in any child"
if ( this . _input . lookBack ( " " ) ) {
this . _output . space _before _token = true ;
}
if ( this . _input . peek ( ) === ":" ) {
// pseudo-element
this . _ch = this . _input . next ( ) ;
this . print _string ( "::" ) ;
} else {
// pseudo-class
this . print _string ( ':' ) ;
}
}
} else if ( this . _ch === '"' || this . _ch === '\'' ) {
2022-07-11 11:25:19 +00:00
var preserveQuoteSpace = previous _ch === '"' || previous _ch === '\'' ;
this . preserveSingleSpace ( preserveQuoteSpace || isAfterSpace ) ;
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch + this . eatString ( this . _ch ) ) ;
this . eatWhitespace ( true ) ;
} else if ( this . _ch === ';' ) {
2022-04-11 08:07:00 +00:00
insideNonSemiColonValues = false ;
2022-01-21 08:28:41 +00:00
if ( parenLevel === 0 ) {
if ( insidePropertyValue ) {
this . outdent ( ) ;
insidePropertyValue = false ;
}
2023-08-17 09:47:40 +00:00
insideNonNestedAtRule = false ;
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
this . eatWhitespace ( true ) ;
// This maintains single line comments on the same
// line. Block comments are also affected, but
// a new line is always output before one inside
// that section
if ( this . _input . peek ( ) !== '/' ) {
this . _output . add _new _line ( ) ;
}
} else {
this . print _string ( this . _ch ) ;
this . eatWhitespace ( true ) ;
this . _output . space _before _token = true ;
}
} else if ( this . _ch === '(' ) { // may be a url
if ( this . _input . lookBack ( "url" ) ) {
this . print _string ( this . _ch ) ;
this . eatWhitespace ( ) ;
parenLevel ++ ;
this . indent ( ) ;
this . _ch = this . _input . next ( ) ;
if ( this . _ch === ')' || this . _ch === '"' || this . _ch === '\'' ) {
this . _input . back ( ) ;
} else if ( this . _ch ) {
this . print _string ( this . _ch + this . eatString ( ')' ) ) ;
if ( parenLevel ) {
parenLevel -- ;
this . outdent ( ) ;
}
}
} else {
2022-07-11 11:25:19 +00:00
var space _needed = false ;
if ( this . _input . lookBack ( "with" ) ) {
// look back is not an accurate solution, we need tokens to confirm without whitespaces
space _needed = true ;
}
this . preserveSingleSpace ( isAfterSpace || space _needed ) ;
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
2022-04-11 08:07:00 +00:00
// handle scss/sass map
if ( insidePropertyValue && previous _ch === "$" && this . _options . selector _separator _newline ) {
this . _output . add _new _line ( ) ;
insideScssMap = true ;
} else {
this . eatWhitespace ( ) ;
parenLevel ++ ;
this . indent ( ) ;
}
2022-01-21 08:28:41 +00:00
}
} else if ( this . _ch === ')' ) {
if ( parenLevel ) {
parenLevel -- ;
this . outdent ( ) ;
}
2022-04-11 08:07:00 +00:00
if ( insideScssMap && this . _input . peek ( ) === ";" && this . _options . selector _separator _newline ) {
insideScssMap = false ;
this . outdent ( ) ;
this . _output . add _new _line ( ) ;
}
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
} else if ( this . _ch === ',' ) {
this . print _string ( this . _ch ) ;
this . eatWhitespace ( true ) ;
2023-08-17 09:47:40 +00:00
if ( this . _options . selector _separator _newline && ( ! insidePropertyValue || insideScssMap ) && parenLevel === 0 && ! insideNonNestedAtRule ) {
2022-01-21 08:28:41 +00:00
this . _output . add _new _line ( ) ;
} else {
this . _output . space _before _token = true ;
}
} else if ( ( this . _ch === '>' || this . _ch === '+' || this . _ch === '~' ) && ! insidePropertyValue && parenLevel === 0 ) {
//handle combinator spacing
if ( this . _options . space _around _combinator ) {
this . _output . space _before _token = true ;
this . print _string ( this . _ch ) ;
this . _output . space _before _token = true ;
} else {
this . print _string ( this . _ch ) ;
this . eatWhitespace ( ) ;
// squash extra whitespace
if ( this . _ch && whitespaceChar . test ( this . _ch ) ) {
this . _ch = '' ;
}
}
} else if ( this . _ch === ']' ) {
this . print _string ( this . _ch ) ;
} else if ( this . _ch === '[' ) {
this . preserveSingleSpace ( isAfterSpace ) ;
this . print _string ( this . _ch ) ;
} else if ( this . _ch === '=' ) { // no whitespace before or after
this . eatWhitespace ( ) ;
this . print _string ( '=' ) ;
if ( whitespaceChar . test ( this . _ch ) ) {
this . _ch = '' ;
}
} else if ( this . _ch === '!' && ! this . _input . lookBack ( "\\" ) ) { // !important
2022-07-11 11:25:19 +00:00
this . _output . space _before _token = true ;
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
} else {
2022-04-11 08:07:00 +00:00
var preserveAfterSpace = previous _ch === '"' || previous _ch === '\'' ;
this . preserveSingleSpace ( preserveAfterSpace || isAfterSpace ) ;
2022-01-21 08:28:41 +00:00
this . print _string ( this . _ch ) ;
2022-04-11 08:07:00 +00:00
if ( ! this . _output . just _added _newline ( ) && this . _input . peek ( ) === '\n' && insideNonSemiColonValues ) {
this . _output . add _new _line ( ) ;
}
2022-01-21 08:28:41 +00:00
}
}
var sweetCode = this . _output . get _code ( eol ) ;
return sweetCode ;
} ;
module . exports . Beautifier = Beautifier ;
/***/ } ) ,
/* 18 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseOptions = ( _ _webpack _require _ _ ( 7 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function Options ( options ) {
BaseOptions . call ( this , options , 'css' ) ;
this . selector _separator _newline = this . _get _boolean ( 'selector_separator_newline' , true ) ;
this . newline _between _rules = this . _get _boolean ( 'newline_between_rules' , true ) ;
var space _around _selector _separator = this . _get _boolean ( 'space_around_selector_separator' ) ;
this . space _around _combinator = this . _get _boolean ( 'space_around_combinator' ) || space _around _selector _separator ;
var brace _style _split = this . _get _selection _list ( 'brace_style' , [ 'collapse' , 'expand' , 'end-expand' , 'none' , 'preserve-inline' ] ) ;
this . brace _style = 'collapse' ;
for ( var bs = 0 ; bs < brace _style _split . length ; bs ++ ) {
if ( brace _style _split [ bs ] !== 'expand' ) {
// default to collapse, as only collapse|expand is implemented for now
this . brace _style = 'collapse' ;
} else {
this . brace _style = brace _style _split [ bs ] ;
}
}
}
Options . prototype = new BaseOptions ( ) ;
module . exports . Options = Options ;
/***/ } ) ,
/* 19 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Beautifier = ( _ _webpack _require _ _ ( 20 ) . Beautifier ) ,
Options = ( _ _webpack _require _ _ ( 21 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function style _html ( html _source , options , js _beautify , css _beautify ) {
var beautifier = new Beautifier ( html _source , options , js _beautify , css _beautify ) ;
return beautifier . beautify ( ) ;
}
module . exports = style _html ;
module . exports . defaultOptions = function ( ) {
return new Options ( ) ;
} ;
/***/ } ) ,
/* 20 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Options = ( _ _webpack _require _ _ ( 21 ) . Options ) ;
var Output = ( _ _webpack _require _ _ ( 3 ) . Output ) ;
var Tokenizer = ( _ _webpack _require _ _ ( 22 ) . Tokenizer ) ;
var TOKEN = ( _ _webpack _require _ _ ( 22 ) . TOKEN ) ;
2022-01-21 08:28:41 +00:00
var lineBreak = /\r\n|[\r\n]/ ;
var allLineBreaks = /\r\n|[\r\n]/g ;
var Printer = function ( options , base _indent _string ) { //handles input/output and some other printing functions
this . indent _level = 0 ;
this . alignment _size = 0 ;
this . max _preserve _newlines = options . max _preserve _newlines ;
this . preserve _newlines = options . preserve _newlines ;
this . _output = new Output ( options , base _indent _string ) ;
} ;
Printer . prototype . current _line _has _match = function ( pattern ) {
return this . _output . current _line . has _match ( pattern ) ;
} ;
Printer . prototype . set _space _before _token = function ( value , non _breaking ) {
this . _output . space _before _token = value ;
this . _output . non _breaking _space = non _breaking ;
} ;
Printer . prototype . set _wrap _point = function ( ) {
this . _output . set _indent ( this . indent _level , this . alignment _size ) ;
this . _output . set _wrap _point ( ) ;
} ;
Printer . prototype . add _raw _token = function ( token ) {
this . _output . add _raw _token ( token ) ;
} ;
Printer . prototype . print _preserved _newlines = function ( raw _token ) {
var newlines = 0 ;
if ( raw _token . type !== TOKEN . TEXT && raw _token . previous . type !== TOKEN . TEXT ) {
newlines = raw _token . newlines ? 1 : 0 ;
}
if ( this . preserve _newlines ) {
newlines = raw _token . newlines < this . max _preserve _newlines + 1 ? raw _token . newlines : this . max _preserve _newlines + 1 ;
}
for ( var n = 0 ; n < newlines ; n ++ ) {
this . print _newline ( n > 0 ) ;
}
return newlines !== 0 ;
} ;
Printer . prototype . traverse _whitespace = function ( raw _token ) {
if ( raw _token . whitespace _before || raw _token . newlines ) {
if ( ! this . print _preserved _newlines ( raw _token ) ) {
this . _output . space _before _token = true ;
}
return true ;
}
return false ;
} ;
Printer . prototype . previous _token _wrapped = function ( ) {
return this . _output . previous _token _wrapped ;
} ;
Printer . prototype . print _newline = function ( force ) {
this . _output . add _new _line ( force ) ;
} ;
Printer . prototype . print _token = function ( token ) {
if ( token . text ) {
this . _output . set _indent ( this . indent _level , this . alignment _size ) ;
this . _output . add _token ( token . text ) ;
}
} ;
Printer . prototype . indent = function ( ) {
this . indent _level ++ ;
} ;
Printer . prototype . get _full _indent = function ( level ) {
level = this . indent _level + ( level || 0 ) ;
if ( level < 1 ) {
return '' ;
}
return this . _output . get _indent _string ( level ) ;
} ;
var get _type _attribute = function ( start _token ) {
var result = null ;
var raw _token = start _token . next ;
// Search attributes for a type attribute
while ( raw _token . type !== TOKEN . EOF && start _token . closed !== raw _token ) {
if ( raw _token . type === TOKEN . ATTRIBUTE && raw _token . text === 'type' ) {
if ( raw _token . next && raw _token . next . type === TOKEN . EQUALS &&
raw _token . next . next && raw _token . next . next . type === TOKEN . VALUE ) {
result = raw _token . next . next . text ;
}
break ;
}
raw _token = raw _token . next ;
}
return result ;
} ;
var get _custom _beautifier _name = function ( tag _check , raw _token ) {
var typeAttribute = null ;
var result = null ;
if ( ! raw _token . closed ) {
return null ;
}
if ( tag _check === 'script' ) {
typeAttribute = 'text/javascript' ;
} else if ( tag _check === 'style' ) {
typeAttribute = 'text/css' ;
}
typeAttribute = get _type _attribute ( raw _token ) || typeAttribute ;
// For script and style tags that have a type attribute, only enable custom beautifiers for matching values
// For those without a type attribute use default;
if ( typeAttribute . search ( 'text/css' ) > - 1 ) {
result = 'css' ;
} else if ( typeAttribute . search ( /module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/ ) > - 1 ) {
result = 'javascript' ;
} else if ( typeAttribute . search ( /(text|application|dojo)\/(x-)?(html)/ ) > - 1 ) {
result = 'html' ;
} else if ( typeAttribute . search ( /test\/null/ ) > - 1 ) {
// Test only mime-type for testing the beautifier when null is passed as beautifing function
result = 'null' ;
}
return result ;
} ;
function in _array ( what , arr ) {
return arr . indexOf ( what ) !== - 1 ;
}
function TagFrame ( parent , parser _token , indent _level ) {
this . parent = parent || null ;
this . tag = parser _token ? parser _token . tag _name : '' ;
this . indent _level = indent _level || 0 ;
this . parser _token = parser _token || null ;
}
function TagStack ( printer ) {
this . _printer = printer ;
this . _current _frame = null ;
}
TagStack . prototype . get _parser _token = function ( ) {
return this . _current _frame ? this . _current _frame . parser _token : null ;
} ;
TagStack . prototype . record _tag = function ( parser _token ) { //function to record a tag and its parent in this.tags Object
var new _frame = new TagFrame ( this . _current _frame , parser _token , this . _printer . indent _level ) ;
this . _current _frame = new _frame ;
} ;
TagStack . prototype . _try _pop _frame = function ( frame ) { //function to retrieve the opening tag to the corresponding closer
var parser _token = null ;
if ( frame ) {
parser _token = frame . parser _token ;
this . _printer . indent _level = frame . indent _level ;
this . _current _frame = frame . parent ;
}
return parser _token ;
} ;
TagStack . prototype . _get _frame = function ( tag _list , stop _list ) { //function to retrieve the opening tag to the corresponding closer
var frame = this . _current _frame ;
while ( frame ) { //till we reach '' (the initial value);
if ( tag _list . indexOf ( frame . tag ) !== - 1 ) { //if this is it use it
break ;
} else if ( stop _list && stop _list . indexOf ( frame . tag ) !== - 1 ) {
frame = null ;
break ;
}
frame = frame . parent ;
}
return frame ;
} ;
TagStack . prototype . try _pop = function ( tag , stop _list ) { //function to retrieve the opening tag to the corresponding closer
var frame = this . _get _frame ( [ tag ] , stop _list ) ;
return this . _try _pop _frame ( frame ) ;
} ;
TagStack . prototype . indent _to _tag = function ( tag _list ) {
var frame = this . _get _frame ( tag _list ) ;
if ( frame ) {
this . _printer . indent _level = frame . indent _level ;
}
} ;
function Beautifier ( source _text , options , js _beautify , css _beautify ) {
//Wrapper function to invoke all the necessary constructors and deal with the output.
this . _source _text = source _text || '' ;
options = options || { } ;
this . _js _beautify = js _beautify ;
this . _css _beautify = css _beautify ;
this . _tag _stack = null ;
// Allow the setting of language/file-type specific options
// with inheritance of overall settings
var optionHtml = new Options ( options , 'html' ) ;
this . _options = optionHtml ;
this . _is _wrap _attributes _force = this . _options . wrap _attributes . substr ( 0 , 'force' . length ) === 'force' ;
this . _is _wrap _attributes _force _expand _multiline = ( this . _options . wrap _attributes === 'force-expand-multiline' ) ;
this . _is _wrap _attributes _force _aligned = ( this . _options . wrap _attributes === 'force-aligned' ) ;
this . _is _wrap _attributes _aligned _multiple = ( this . _options . wrap _attributes === 'aligned-multiple' ) ;
this . _is _wrap _attributes _preserve = this . _options . wrap _attributes . substr ( 0 , 'preserve' . length ) === 'preserve' ;
this . _is _wrap _attributes _preserve _aligned = ( this . _options . wrap _attributes === 'preserve-aligned' ) ;
}
Beautifier . prototype . beautify = function ( ) {
// if disabled, return the input unchanged.
if ( this . _options . disabled ) {
return this . _source _text ;
}
var source _text = this . _source _text ;
var eol = this . _options . eol ;
if ( this . _options . eol === 'auto' ) {
eol = '\n' ;
if ( source _text && lineBreak . test ( source _text ) ) {
eol = source _text . match ( lineBreak ) [ 0 ] ;
}
}
// HACK: newline parsing inconsistent. This brute force normalizes the input.
source _text = source _text . replace ( allLineBreaks , '\n' ) ;
var baseIndentString = source _text . match ( /^[\t ]*/ ) [ 0 ] ;
var last _token = {
text : '' ,
type : ''
} ;
var last _tag _token = new TagOpenParserToken ( ) ;
var printer = new Printer ( this . _options , baseIndentString ) ;
var tokens = new Tokenizer ( source _text , this . _options ) . tokenize ( ) ;
this . _tag _stack = new TagStack ( printer ) ;
var parser _token = null ;
var raw _token = tokens . next ( ) ;
while ( raw _token . type !== TOKEN . EOF ) {
if ( raw _token . type === TOKEN . TAG _OPEN || raw _token . type === TOKEN . COMMENT ) {
2023-08-17 09:47:40 +00:00
parser _token = this . _handle _tag _open ( printer , raw _token , last _tag _token , last _token , tokens ) ;
2022-01-21 08:28:41 +00:00
last _tag _token = parser _token ;
} else if ( ( raw _token . type === TOKEN . ATTRIBUTE || raw _token . type === TOKEN . EQUALS || raw _token . type === TOKEN . VALUE ) ||
( raw _token . type === TOKEN . TEXT && ! last _tag _token . tag _complete ) ) {
2023-08-17 09:47:40 +00:00
parser _token = this . _handle _inside _tag ( printer , raw _token , last _tag _token , last _token ) ;
2022-01-21 08:28:41 +00:00
} else if ( raw _token . type === TOKEN . TAG _CLOSE ) {
parser _token = this . _handle _tag _close ( printer , raw _token , last _tag _token ) ;
} else if ( raw _token . type === TOKEN . TEXT ) {
parser _token = this . _handle _text ( printer , raw _token , last _tag _token ) ;
} else {
// This should never happen, but if it does. Print the raw token
printer . add _raw _token ( raw _token ) ;
}
last _token = parser _token ;
raw _token = tokens . next ( ) ;
}
var sweet _code = printer . _output . get _code ( eol ) ;
return sweet _code ;
} ;
Beautifier . prototype . _handle _tag _close = function ( printer , raw _token , last _tag _token ) {
var parser _token = {
text : raw _token . text ,
type : raw _token . type
} ;
printer . alignment _size = 0 ;
last _tag _token . tag _complete = true ;
printer . set _space _before _token ( raw _token . newlines || raw _token . whitespace _before !== '' , true ) ;
if ( last _tag _token . is _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else {
if ( last _tag _token . tag _start _char === '<' ) {
printer . set _space _before _token ( raw _token . text [ 0 ] === '/' , true ) ; // space before />, no space before >
if ( this . _is _wrap _attributes _force _expand _multiline && last _tag _token . has _wrapped _attrs ) {
printer . print _newline ( false ) ;
}
}
printer . print _token ( raw _token ) ;
}
if ( last _tag _token . indent _content &&
! ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) ) {
printer . indent ( ) ;
// only indent once per opened tag
last _tag _token . indent _content = false ;
}
if ( ! last _tag _token . is _inline _element &&
! ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) ) {
printer . set _wrap _point ( ) ;
}
return parser _token ;
} ;
2023-08-17 09:47:40 +00:00
Beautifier . prototype . _handle _inside _tag = function ( printer , raw _token , last _tag _token , last _token ) {
2022-01-21 08:28:41 +00:00
var wrapped = last _tag _token . has _wrapped _attrs ;
var parser _token = {
text : raw _token . text ,
type : raw _token . type
} ;
printer . set _space _before _token ( raw _token . newlines || raw _token . whitespace _before !== '' , true ) ;
if ( last _tag _token . is _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else if ( last _tag _token . tag _start _char === '{' && raw _token . type === TOKEN . TEXT ) {
// For the insides of handlebars allow newlines or a single space between open and contents
if ( printer . print _preserved _newlines ( raw _token ) ) {
raw _token . newlines = 0 ;
printer . add _raw _token ( raw _token ) ;
} else {
printer . print _token ( raw _token ) ;
}
} else {
if ( raw _token . type === TOKEN . ATTRIBUTE ) {
printer . set _space _before _token ( true ) ;
} else if ( raw _token . type === TOKEN . EQUALS ) { //no space before =
printer . set _space _before _token ( false ) ;
} else if ( raw _token . type === TOKEN . VALUE && raw _token . previous . type === TOKEN . EQUALS ) { //no space before value
printer . set _space _before _token ( false ) ;
}
if ( raw _token . type === TOKEN . ATTRIBUTE && last _tag _token . tag _start _char === '<' ) {
if ( this . _is _wrap _attributes _preserve || this . _is _wrap _attributes _preserve _aligned ) {
printer . traverse _whitespace ( raw _token ) ;
wrapped = wrapped || raw _token . newlines !== 0 ;
}
2023-08-17 09:47:40 +00:00
// Wrap for 'force' options, and if the number of attributes is at least that specified in 'wrap_attributes_min_attrs':
// 1. always wrap the second and beyond attributes
// 2. wrap the first attribute only if 'force-expand-multiline' is specified
if ( this . _is _wrap _attributes _force &&
last _tag _token . attr _count >= this . _options . wrap _attributes _min _attrs &&
( last _token . type !== TOKEN . TAG _OPEN || // ie. second attribute and beyond
this . _is _wrap _attributes _force _expand _multiline ) ) {
printer . print _newline ( false ) ;
wrapped = true ;
2022-01-21 08:28:41 +00:00
}
}
printer . print _token ( raw _token ) ;
wrapped = wrapped || printer . previous _token _wrapped ( ) ;
last _tag _token . has _wrapped _attrs = wrapped ;
}
return parser _token ;
} ;
Beautifier . prototype . _handle _text = function ( printer , raw _token , last _tag _token ) {
var parser _token = {
text : raw _token . text ,
type : 'TK_CONTENT'
} ;
if ( last _tag _token . custom _beautifier _name ) { //check if we need to format javascript
this . _print _custom _beatifier _text ( printer , raw _token , last _tag _token ) ;
} else if ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else {
printer . traverse _whitespace ( raw _token ) ;
printer . print _token ( raw _token ) ;
}
return parser _token ;
} ;
Beautifier . prototype . _print _custom _beatifier _text = function ( printer , raw _token , last _tag _token ) {
var local = this ;
if ( raw _token . text !== '' ) {
var text = raw _token . text ,
_beautifier ,
script _indent _level = 1 ,
pre = '' ,
post = '' ;
if ( last _tag _token . custom _beautifier _name === 'javascript' && typeof this . _js _beautify === 'function' ) {
_beautifier = this . _js _beautify ;
} else if ( last _tag _token . custom _beautifier _name === 'css' && typeof this . _css _beautify === 'function' ) {
_beautifier = this . _css _beautify ;
} else if ( last _tag _token . custom _beautifier _name === 'html' ) {
_beautifier = function ( html _source , options ) {
var beautifier = new Beautifier ( html _source , options , local . _js _beautify , local . _css _beautify ) ;
return beautifier . beautify ( ) ;
} ;
}
if ( this . _options . indent _scripts === "keep" ) {
script _indent _level = 0 ;
} else if ( this . _options . indent _scripts === "separate" ) {
script _indent _level = - printer . indent _level ;
}
var indentation = printer . get _full _indent ( script _indent _level ) ;
// if there is at least one empty line at the end of this text, strip it
// we'll be adding one back after the text but before the containing tag.
text = text . replace ( /\n[ \t]*$/ , '' ) ;
// Handle the case where content is wrapped in a comment or cdata.
if ( last _tag _token . custom _beautifier _name !== 'html' &&
text [ 0 ] === '<' && text . match ( /^(<!--|<!\[CDATA\[)/ ) ) {
var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/ . exec ( text ) ;
// if we start to wrap but don't finish, print raw
if ( ! matched ) {
printer . add _raw _token ( raw _token ) ;
return ;
}
pre = indentation + matched [ 1 ] + '\n' ;
text = matched [ 4 ] ;
if ( matched [ 5 ] ) {
post = indentation + matched [ 5 ] ;
}
// if there is at least one empty line at the end of this text, strip it
// we'll be adding one back after the text but before the containing tag.
text = text . replace ( /\n[ \t]*$/ , '' ) ;
if ( matched [ 2 ] || matched [ 3 ] . indexOf ( '\n' ) !== - 1 ) {
// if the first line of the non-comment text has spaces
// use that as the basis for indenting in null case.
matched = matched [ 3 ] . match ( /[ \t]+$/ ) ;
if ( matched ) {
raw _token . whitespace _before = matched [ 0 ] ;
}
}
}
if ( text ) {
if ( _beautifier ) {
// call the Beautifier if avaliable
var Child _options = function ( ) {
this . eol = '\n' ;
} ;
Child _options . prototype = this . _options . raw _options ;
var child _options = new Child _options ( ) ;
text = _beautifier ( indentation + text , child _options ) ;
} else {
// simply indent the string otherwise
var white = raw _token . whitespace _before ;
if ( white ) {
text = text . replace ( new RegExp ( '\n(' + white + ')?' , 'g' ) , '\n' ) ;
}
text = indentation + text . replace ( /\n/g , '\n' + indentation ) ;
}
}
if ( pre ) {
if ( ! text ) {
text = pre + post ;
} else {
text = pre + text + '\n' + post ;
}
}
printer . print _newline ( false ) ;
if ( text ) {
raw _token . text = text ;
raw _token . whitespace _before = '' ;
raw _token . newlines = 0 ;
printer . add _raw _token ( raw _token ) ;
printer . print _newline ( true ) ;
}
}
} ;
2023-08-17 09:47:40 +00:00
Beautifier . prototype . _handle _tag _open = function ( printer , raw _token , last _tag _token , last _token , tokens ) {
2022-01-21 08:28:41 +00:00
var parser _token = this . _get _tag _open _token ( raw _token ) ;
if ( ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) &&
! last _tag _token . is _empty _element &&
2023-08-17 09:47:40 +00:00
raw _token . type === TOKEN . TAG _OPEN && ! parser _token . is _start _tag ) {
2022-01-21 08:28:41 +00:00
// End element tags for unformatted or content_unformatted elements
// are printed raw to keep any newlines inside them exactly the same.
printer . add _raw _token ( raw _token ) ;
parser _token . start _tag _token = this . _tag _stack . try _pop ( parser _token . tag _name ) ;
} else {
printer . traverse _whitespace ( raw _token ) ;
this . _set _tag _position ( printer , raw _token , parser _token , last _tag _token , last _token ) ;
if ( ! parser _token . is _inline _element ) {
printer . set _wrap _point ( ) ;
}
printer . print _token ( raw _token ) ;
}
2023-08-17 09:47:40 +00:00
// count the number of attributes
if ( parser _token . is _start _tag && this . _is _wrap _attributes _force ) {
var peek _index = 0 ;
var peek _token ;
do {
peek _token = tokens . peek ( peek _index ) ;
if ( peek _token . type === TOKEN . ATTRIBUTE ) {
parser _token . attr _count += 1 ;
}
peek _index += 1 ;
} while ( peek _token . type !== TOKEN . EOF && peek _token . type !== TOKEN . TAG _CLOSE ) ;
}
2022-01-21 08:28:41 +00:00
//indent attributes an auto, forced, aligned or forced-align line-wrap
if ( this . _is _wrap _attributes _force _aligned || this . _is _wrap _attributes _aligned _multiple || this . _is _wrap _attributes _preserve _aligned ) {
parser _token . alignment _size = raw _token . text . length + 1 ;
}
if ( ! parser _token . tag _complete && ! parser _token . is _unformatted ) {
printer . alignment _size = parser _token . alignment _size ;
}
return parser _token ;
} ;
var TagOpenParserToken = function ( parent , raw _token ) {
this . parent = parent || null ;
this . text = '' ;
this . type = 'TK_TAG_OPEN' ;
this . tag _name = '' ;
this . is _inline _element = false ;
this . is _unformatted = false ;
this . is _content _unformatted = false ;
this . is _empty _element = false ;
this . is _start _tag = false ;
this . is _end _tag = false ;
this . indent _content = false ;
this . multiline _content = false ;
this . custom _beautifier _name = null ;
this . start _tag _token = null ;
this . attr _count = 0 ;
this . has _wrapped _attrs = false ;
this . alignment _size = 0 ;
this . tag _complete = false ;
this . tag _start _char = '' ;
this . tag _check = '' ;
if ( ! raw _token ) {
this . tag _complete = true ;
} else {
var tag _check _match ;
this . tag _start _char = raw _token . text [ 0 ] ;
this . text = raw _token . text ;
if ( this . tag _start _char === '<' ) {
tag _check _match = raw _token . text . match ( /^<([^\s>]*)/ ) ;
this . tag _check = tag _check _match ? tag _check _match [ 1 ] : '' ;
} else {
2022-07-11 11:25:19 +00:00
tag _check _match = raw _token . text . match ( /^{{~?(?:[\^]|#\*?)?([^\s}]+)/ ) ;
2022-01-21 08:28:41 +00:00
this . tag _check = tag _check _match ? tag _check _match [ 1 ] : '' ;
2022-07-11 11:25:19 +00:00
// handle "{{#> myPartial}}" or "{{~#> myPartial}}"
if ( ( raw _token . text . startsWith ( '{{#>' ) || raw _token . text . startsWith ( '{{~#>' ) ) && this . tag _check [ 0 ] === '>' ) {
if ( this . tag _check === '>' && raw _token . next !== null ) {
this . tag _check = raw _token . next . text . split ( ' ' ) [ 0 ] ;
} else {
this . tag _check = raw _token . text . split ( '>' ) [ 1 ] ;
}
2022-01-21 08:28:41 +00:00
}
}
2022-07-11 11:25:19 +00:00
2022-01-21 08:28:41 +00:00
this . tag _check = this . tag _check . toLowerCase ( ) ;
if ( raw _token . type === TOKEN . COMMENT ) {
this . tag _complete = true ;
}
this . is _start _tag = this . tag _check . charAt ( 0 ) !== '/' ;
this . tag _name = ! this . is _start _tag ? this . tag _check . substr ( 1 ) : this . tag _check ;
this . is _end _tag = ! this . is _start _tag ||
( raw _token . closed && raw _token . closed . text === '/>' ) ;
2022-07-11 11:25:19 +00:00
// if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2
var handlebar _starts = 2 ;
if ( this . tag _start _char === '{' && this . text . length >= 3 ) {
if ( this . text . charAt ( 2 ) === '~' ) {
handlebar _starts = 3 ;
}
}
2022-01-21 08:28:41 +00:00
// handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
this . is _end _tag = this . is _end _tag ||
2022-07-11 11:25:19 +00:00
( this . tag _start _char === '{' && ( this . text . length < 3 || ( /[^#\^]/ . test ( this . text . charAt ( handlebar _starts ) ) ) ) ) ;
2022-01-21 08:28:41 +00:00
}
} ;
Beautifier . prototype . _get _tag _open _token = function ( raw _token ) { //function to get a full tag and parse its type
var parser _token = new TagOpenParserToken ( this . _tag _stack . get _parser _token ( ) , raw _token ) ;
parser _token . alignment _size = this . _options . wrap _attributes _indent _size ;
parser _token . is _end _tag = parser _token . is _end _tag ||
in _array ( parser _token . tag _check , this . _options . void _elements ) ;
parser _token . is _empty _element = parser _token . tag _complete ||
( parser _token . is _start _tag && parser _token . is _end _tag ) ;
parser _token . is _unformatted = ! parser _token . tag _complete && in _array ( parser _token . tag _check , this . _options . unformatted ) ;
parser _token . is _content _unformatted = ! parser _token . is _empty _element && in _array ( parser _token . tag _check , this . _options . content _unformatted ) ;
2023-08-17 09:47:40 +00:00
parser _token . is _inline _element = in _array ( parser _token . tag _name , this . _options . inline ) || ( this . _options . inline _custom _elements && parser _token . tag _name . includes ( "-" ) ) || parser _token . tag _start _char === '{' ;
2022-01-21 08:28:41 +00:00
return parser _token ;
} ;
Beautifier . prototype . _set _tag _position = function ( printer , raw _token , parser _token , last _tag _token , last _token ) {
if ( ! parser _token . is _empty _element ) {
if ( parser _token . is _end _tag ) { //this tag is a double tag so check for tag-ending
parser _token . start _tag _token = this . _tag _stack . try _pop ( parser _token . tag _name ) ; //remove it and all ancestors
} else { // it's a start-tag
// check if this tag is starting an element that has optional end element
// and do an ending needed
if ( this . _do _optional _end _element ( parser _token ) ) {
if ( ! parser _token . is _inline _element ) {
printer . print _newline ( false ) ;
}
}
this . _tag _stack . record _tag ( parser _token ) ; //push it on the tag stack
if ( ( parser _token . tag _name === 'script' || parser _token . tag _name === 'style' ) &&
! ( parser _token . is _unformatted || parser _token . is _content _unformatted ) ) {
parser _token . custom _beautifier _name = get _custom _beautifier _name ( parser _token . tag _check , raw _token ) ;
}
}
}
if ( in _array ( parser _token . tag _check , this . _options . extra _liners ) ) { //check if this double needs an extra line
printer . print _newline ( false ) ;
if ( ! printer . _output . just _added _blankline ( ) ) {
printer . print _newline ( true ) ;
}
}
if ( parser _token . is _empty _element ) { //if this tag name is a single tag type (either in the list or has a closing /)
// if you hit an else case, reset the indent level if you are inside an:
// 'if', 'unless', or 'each' block.
if ( parser _token . tag _start _char === '{' && parser _token . tag _check === 'else' ) {
this . _tag _stack . indent _to _tag ( [ 'if' , 'unless' , 'each' ] ) ;
parser _token . indent _content = true ;
// Don't add a newline if opening {{#if}} tag is on the current line
var foundIfOnCurrentLine = printer . current _line _has _match ( /{{#if/ ) ;
if ( ! foundIfOnCurrentLine ) {
printer . print _newline ( false ) ;
}
}
// Don't add a newline before elements that should remain where they are.
if ( parser _token . tag _name === '!--' && last _token . type === TOKEN . TAG _CLOSE &&
last _tag _token . is _end _tag && parser _token . text . indexOf ( '\n' ) === - 1 ) {
//Do nothing. Leave comments on same line.
} else {
if ( ! ( parser _token . is _inline _element || parser _token . is _unformatted ) ) {
printer . print _newline ( false ) ;
}
this . _calcluate _parent _multiline ( printer , parser _token ) ;
}
} else if ( parser _token . is _end _tag ) { //this tag is a double tag so check for tag-ending
var do _end _expand = false ;
// deciding whether a block is multiline should not be this hard
do _end _expand = parser _token . start _tag _token && parser _token . start _tag _token . multiline _content ;
do _end _expand = do _end _expand || ( ! parser _token . is _inline _element &&
! ( last _tag _token . is _inline _element || last _tag _token . is _unformatted ) &&
! ( last _token . type === TOKEN . TAG _CLOSE && parser _token . start _tag _token === last _tag _token ) &&
last _token . type !== 'TK_CONTENT'
) ;
if ( parser _token . is _content _unformatted || parser _token . is _unformatted ) {
do _end _expand = false ;
}
if ( do _end _expand ) {
printer . print _newline ( false ) ;
}
} else { // it's a start-tag
parser _token . indent _content = ! parser _token . custom _beautifier _name ;
if ( parser _token . tag _start _char === '<' ) {
if ( parser _token . tag _name === 'html' ) {
parser _token . indent _content = this . _options . indent _inner _html ;
} else if ( parser _token . tag _name === 'head' ) {
parser _token . indent _content = this . _options . indent _head _inner _html ;
} else if ( parser _token . tag _name === 'body' ) {
parser _token . indent _content = this . _options . indent _body _inner _html ;
}
}
if ( ! ( parser _token . is _inline _element || parser _token . is _unformatted ) &&
( last _token . type !== 'TK_CONTENT' || parser _token . is _content _unformatted ) ) {
printer . print _newline ( false ) ;
}
this . _calcluate _parent _multiline ( printer , parser _token ) ;
}
} ;
Beautifier . prototype . _calcluate _parent _multiline = function ( printer , parser _token ) {
if ( parser _token . parent && printer . _output . just _added _newline ( ) &&
! ( ( parser _token . is _inline _element || parser _token . is _unformatted ) && parser _token . parent . is _inline _element ) ) {
parser _token . parent . multiline _content = true ;
}
} ;
//To be used for <p> tag special case:
2023-08-17 09:47:40 +00:00
var p _closers = [ 'address' , 'article' , 'aside' , 'blockquote' , 'details' , 'div' , 'dl' , 'fieldset' , 'figcaption' , 'figure' , 'footer' , 'form' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' , 'header' , 'hr' , 'main' , 'menu' , 'nav' , 'ol' , 'p' , 'pre' , 'section' , 'table' , 'ul' ] ;
2022-01-21 08:28:41 +00:00
var p _parent _excludes = [ 'a' , 'audio' , 'del' , 'ins' , 'map' , 'noscript' , 'video' ] ;
Beautifier . prototype . _do _optional _end _element = function ( parser _token ) {
var result = null ;
// NOTE: cases of "if there is no more content in the parent element"
// are handled automatically by the beautifier.
// It assumes parent or ancestor close tag closes all children.
// https://www.w3.org/TR/html5/syntax.html#optional-tags
if ( parser _token . is _empty _element || ! parser _token . is _start _tag || ! parser _token . parent ) {
return ;
}
if ( parser _token . tag _name === 'body' ) {
// A head element’ s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
result = result || this . _tag _stack . try _pop ( 'head' ) ;
//} else if (parser_token.tag_name === 'body') {
// DONE: A body element’ s end tag may be omitted if the body element is not immediately followed by a comment.
} else if ( parser _token . tag _name === 'li' ) {
// An li element’ s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
2023-08-17 09:47:40 +00:00
result = result || this . _tag _stack . try _pop ( 'li' , [ 'ol' , 'ul' , 'menu' ] ) ;
2022-01-21 08:28:41 +00:00
} else if ( parser _token . tag _name === 'dd' || parser _token . tag _name === 'dt' ) {
// A dd element’ s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
// A dt element’ s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
result = result || this . _tag _stack . try _pop ( 'dt' , [ 'dl' ] ) ;
result = result || this . _tag _stack . try _pop ( 'dd' , [ 'dl' ] ) ;
} else if ( parser _token . parent . tag _name === 'p' && p _closers . indexOf ( parser _token . tag _name ) !== - 1 ) {
// IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method
// check for the parent element is an HTML element that is not an <a>, <audio>, <del>, <ins>, <map>, <noscript>, or <video> element, or an autonomous custom element.
// To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above.
// But to start with (if we ignore "autonomous custom elements") the exclusion would be fine.
var p _parent = parser _token . parent . parent ;
if ( ! p _parent || p _parent _excludes . indexOf ( p _parent . tag _name ) === - 1 ) {
result = result || this . _tag _stack . try _pop ( 'p' ) ;
}
} else if ( parser _token . tag _name === 'rp' || parser _token . tag _name === 'rt' ) {
// An rt element’ s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
// An rp element’ s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'rt' , [ 'ruby' , 'rtc' ] ) ;
result = result || this . _tag _stack . try _pop ( 'rp' , [ 'ruby' , 'rtc' ] ) ;
} else if ( parser _token . tag _name === 'optgroup' ) {
// An optgroup element’ s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
// An option element’ s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'optgroup' , [ 'select' ] ) ;
//result = result || this._tag_stack.try_pop('option', ['select']);
} else if ( parser _token . tag _name === 'option' ) {
// An option element’ s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'option' , [ 'select' , 'datalist' , 'optgroup' ] ) ;
} else if ( parser _token . tag _name === 'colgroup' ) {
// DONE: A colgroup element’ s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
} else if ( parser _token . tag _name === 'thead' ) {
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
//} else if (parser_token.tag_name === 'caption') {
// DONE: A caption element’ s end tag may be omitted if the caption element is not immediately followed by a space character or a comment.
} else if ( parser _token . tag _name === 'tbody' || parser _token . tag _name === 'tfoot' ) {
// A thead element’ s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
// A tbody element’ s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'thead' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'tbody' , [ 'table' ] ) ;
//} else if (parser_token.tag_name === 'tfoot') {
// DONE: A tfoot element’ s end tag may be omitted if there is no more content in the parent element.
} else if ( parser _token . tag _name === 'tr' ) {
// A tr element’ s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'tr' , [ 'table' , 'thead' , 'tbody' , 'tfoot' ] ) ;
} else if ( parser _token . tag _name === 'th' || parser _token . tag _name === 'td' ) {
// A td element’ s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
// A th element’ s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'td' , [ 'table' , 'thead' , 'tbody' , 'tfoot' , 'tr' ] ) ;
result = result || this . _tag _stack . try _pop ( 'th' , [ 'table' , 'thead' , 'tbody' , 'tfoot' , 'tr' ] ) ;
}
// Start element omission not handled currently
// A head element’ s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.
// A tbody element’ s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’ t be omitted if the element is empty.)
// A colgroup element’ s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’ t be omitted if the element is empty.)
// Fix up the parent of the parser token
parser _token . parent = this . _tag _stack . get _parser _token ( ) ;
return result ;
} ;
module . exports . Beautifier = Beautifier ;
/***/ } ) ,
/* 21 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseOptions = ( _ _webpack _require _ _ ( 7 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function Options ( options ) {
BaseOptions . call ( this , options , 'html' ) ;
if ( this . templating . length === 1 && this . templating [ 0 ] === 'auto' ) {
this . templating = [ 'django' , 'erb' , 'handlebars' , 'php' ] ;
}
this . indent _inner _html = this . _get _boolean ( 'indent_inner_html' ) ;
this . indent _body _inner _html = this . _get _boolean ( 'indent_body_inner_html' , true ) ;
this . indent _head _inner _html = this . _get _boolean ( 'indent_head_inner_html' , true ) ;
this . indent _handlebars = this . _get _boolean ( 'indent_handlebars' , true ) ;
this . wrap _attributes = this . _get _selection ( 'wrap_attributes' ,
[ 'auto' , 'force' , 'force-aligned' , 'force-expand-multiline' , 'aligned-multiple' , 'preserve' , 'preserve-aligned' ] ) ;
2023-08-17 09:47:40 +00:00
this . wrap _attributes _min _attrs = this . _get _number ( 'wrap_attributes_min_attrs' , 2 ) ;
2022-01-21 08:28:41 +00:00
this . wrap _attributes _indent _size = this . _get _number ( 'wrap_attributes_indent_size' , this . indent _size ) ;
this . extra _liners = this . _get _array ( 'extra_liners' , [ 'head' , 'body' , '/html' ] ) ;
// Block vs inline elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
// https://www.w3.org/TR/html5/dom.html#phrasing-content
this . inline = this . _get _array ( 'inline' , [
'a' , 'abbr' , 'area' , 'audio' , 'b' , 'bdi' , 'bdo' , 'br' , 'button' , 'canvas' , 'cite' ,
'code' , 'data' , 'datalist' , 'del' , 'dfn' , 'em' , 'embed' , 'i' , 'iframe' , 'img' ,
'input' , 'ins' , 'kbd' , 'keygen' , 'label' , 'map' , 'mark' , 'math' , 'meter' , 'noscript' ,
'object' , 'output' , 'progress' , 'q' , 'ruby' , 's' , 'samp' , /* 'script', */ 'select' , 'small' ,
'span' , 'strong' , 'sub' , 'sup' , 'svg' , 'template' , 'textarea' , 'time' , 'u' , 'var' ,
'video' , 'wbr' , 'text' ,
// obsolete inline tags
'acronym' , 'big' , 'strike' , 'tt'
] ) ;
2023-08-17 09:47:40 +00:00
this . inline _custom _elements = this . _get _boolean ( 'inline_custom_elements' , true ) ;
2022-01-21 08:28:41 +00:00
this . void _elements = this . _get _array ( 'void_elements' , [
// HTLM void elements - aka self-closing tags - aka singletons
// https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
'area' , 'base' , 'br' , 'col' , 'embed' , 'hr' , 'img' , 'input' , 'keygen' ,
'link' , 'menuitem' , 'meta' , 'param' , 'source' , 'track' , 'wbr' ,
// NOTE: Optional tags are too complex for a simple list
// they are hard coded in _do_optional_end_element
// Doctype and xml elements
'!doctype' , '?xml' ,
// obsolete tags
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
'basefont' , 'isindex'
] ) ;
this . unformatted = this . _get _array ( 'unformatted' , [ ] ) ;
this . content _unformatted = this . _get _array ( 'content_unformatted' , [
'pre' , 'textarea'
] ) ;
this . unformatted _content _delimiter = this . _get _characters ( 'unformatted_content_delimiter' ) ;
this . indent _scripts = this . _get _selection ( 'indent_scripts' , [ 'normal' , 'keep' , 'separate' ] ) ;
}
Options . prototype = new BaseOptions ( ) ;
module . exports . Options = Options ;
/***/ } ) ,
/* 22 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseTokenizer = ( _ _webpack _require _ _ ( 10 ) . Tokenizer ) ;
var BASETOKEN = ( _ _webpack _require _ _ ( 10 ) . TOKEN ) ;
var Directives = ( _ _webpack _require _ _ ( 14 ) . Directives ) ;
var TemplatablePattern = ( _ _webpack _require _ _ ( 15 ) . TemplatablePattern ) ;
var Pattern = ( _ _webpack _require _ _ ( 13 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
var TOKEN = {
TAG _OPEN : 'TK_TAG_OPEN' ,
TAG _CLOSE : 'TK_TAG_CLOSE' ,
ATTRIBUTE : 'TK_ATTRIBUTE' ,
EQUALS : 'TK_EQUALS' ,
VALUE : 'TK_VALUE' ,
COMMENT : 'TK_COMMENT' ,
TEXT : 'TK_TEXT' ,
UNKNOWN : 'TK_UNKNOWN' ,
START : BASETOKEN . START ,
RAW : BASETOKEN . RAW ,
EOF : BASETOKEN . EOF
} ;
var directives _core = new Directives ( /<\!--/ , /-->/ ) ;
var Tokenizer = function ( input _string , options ) {
BaseTokenizer . call ( this , input _string , options ) ;
this . _current _tag _name = '' ;
// Words end at whitespace or when a tag starts
// if we are indenting handlebars, they are considered tags
var templatable _reader = new TemplatablePattern ( this . _input ) . read _options ( this . _options ) ;
var pattern _reader = new Pattern ( this . _input ) ;
this . _ _patterns = {
word : templatable _reader . until ( /[\n\r\t <]/ ) ,
single _quote : templatable _reader . until _after ( /'/ ) ,
double _quote : templatable _reader . until _after ( /"/ ) ,
attribute : templatable _reader . until ( /[\n\r\t =>]|\/>/ ) ,
element _name : templatable _reader . until ( /[\n\r\t >\/]/ ) ,
handlebars _comment : pattern _reader . starting _with ( /{{!--/ ) . until _after ( /--}}/ ) ,
handlebars : pattern _reader . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
handlebars _open : pattern _reader . until ( /[\n\r\t }]/ ) ,
handlebars _raw _close : pattern _reader . until ( /}}/ ) ,
comment : pattern _reader . starting _with ( /<!--/ ) . until _after ( /-->/ ) ,
cdata : pattern _reader . starting _with ( /<!\[CDATA\[/ ) . until _after ( /]]>/ ) ,
// https://en.wikipedia.org/wiki/Conditional_comment
conditional _comment : pattern _reader . starting _with ( /<!\[/ ) . until _after ( /]>/ ) ,
processing : pattern _reader . starting _with ( /<\?/ ) . until _after ( /\?>/ )
} ;
if ( this . _options . indent _handlebars ) {
this . _ _patterns . word = this . _ _patterns . word . exclude ( 'handlebars' ) ;
}
this . _unformatted _content _delimiter = null ;
if ( this . _options . unformatted _content _delimiter ) {
var literal _regexp = this . _input . get _literal _regexp ( this . _options . unformatted _content _delimiter ) ;
this . _ _patterns . unformatted _content _delimiter =
pattern _reader . matching ( literal _regexp )
. until _after ( literal _regexp ) ;
}
} ;
Tokenizer . prototype = new BaseTokenizer ( ) ;
Tokenizer . prototype . _is _comment = function ( current _token ) { // jshint unused:false
return false ; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
} ;
Tokenizer . prototype . _is _opening = function ( current _token ) {
return current _token . type === TOKEN . TAG _OPEN ;
} ;
Tokenizer . prototype . _is _closing = function ( current _token , open _token ) {
return current _token . type === TOKEN . TAG _CLOSE &&
( open _token && (
( ( current _token . text === '>' || current _token . text === '/>' ) && open _token . text [ 0 ] === '<' ) ||
( current _token . text === '}}' && open _token . text [ 0 ] === '{' && open _token . text [ 1 ] === '{' ) ) ) ;
} ;
Tokenizer . prototype . _reset = function ( ) {
this . _current _tag _name = '' ;
} ;
Tokenizer . prototype . _get _next _token = function ( previous _token , open _token ) { // jshint unused:false
var token = null ;
this . _readWhitespace ( ) ;
var c = this . _input . peek ( ) ;
if ( c === null ) {
return this . _create _token ( TOKEN . EOF , '' ) ;
}
token = token || this . _read _open _handlebars ( c , open _token ) ;
token = token || this . _read _attribute ( c , previous _token , open _token ) ;
token = token || this . _read _close ( c , open _token ) ;
token = token || this . _read _raw _content ( c , previous _token , open _token ) ;
token = token || this . _read _content _word ( c ) ;
token = token || this . _read _comment _or _cdata ( c ) ;
token = token || this . _read _processing ( c ) ;
token = token || this . _read _open ( c , open _token ) ;
token = token || this . _create _token ( TOKEN . UNKNOWN , this . _input . next ( ) ) ;
return token ;
} ;
Tokenizer . prototype . _read _comment _or _cdata = function ( c ) { // jshint unused:false
var token = null ;
var resulting _string = null ;
var directives = null ;
if ( c === '<' ) {
var peek1 = this . _input . peek ( 1 ) ;
// We treat all comments as literals, even more than preformatted tags
// we only look for the appropriate closing marker
if ( peek1 === '!' ) {
resulting _string = this . _ _patterns . comment . read ( ) ;
// only process directive on html comments
if ( resulting _string ) {
directives = directives _core . get _directives ( resulting _string ) ;
if ( directives && directives . ignore === 'start' ) {
resulting _string += directives _core . readIgnored ( this . _input ) ;
}
} else {
resulting _string = this . _ _patterns . cdata . read ( ) ;
}
}
if ( resulting _string ) {
token = this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
token . directives = directives ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _processing = function ( c ) { // jshint unused:false
var token = null ;
var resulting _string = null ;
var directives = null ;
if ( c === '<' ) {
var peek1 = this . _input . peek ( 1 ) ;
if ( peek1 === '!' || peek1 === '?' ) {
resulting _string = this . _ _patterns . conditional _comment . read ( ) ;
resulting _string = resulting _string || this . _ _patterns . processing . read ( ) ;
}
if ( resulting _string ) {
token = this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
token . directives = directives ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _open = function ( c , open _token ) {
var resulting _string = null ;
var token = null ;
if ( ! open _token ) {
if ( c === '<' ) {
resulting _string = this . _input . next ( ) ;
if ( this . _input . peek ( ) === '/' ) {
resulting _string += this . _input . next ( ) ;
}
resulting _string += this . _ _patterns . element _name . read ( ) ;
token = this . _create _token ( TOKEN . TAG _OPEN , resulting _string ) ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _open _handlebars = function ( c , open _token ) {
var resulting _string = null ;
var token = null ;
if ( ! open _token ) {
if ( this . _options . indent _handlebars && c === '{' && this . _input . peek ( 1 ) === '{' ) {
if ( this . _input . peek ( 2 ) === '!' ) {
resulting _string = this . _ _patterns . handlebars _comment . read ( ) ;
resulting _string = resulting _string || this . _ _patterns . handlebars . read ( ) ;
token = this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
} else {
resulting _string = this . _ _patterns . handlebars _open . read ( ) ;
token = this . _create _token ( TOKEN . TAG _OPEN , resulting _string ) ;
}
}
}
return token ;
} ;
Tokenizer . prototype . _read _close = function ( c , open _token ) {
var resulting _string = null ;
var token = null ;
if ( open _token ) {
if ( open _token . text [ 0 ] === '<' && ( c === '>' || ( c === '/' && this . _input . peek ( 1 ) === '>' ) ) ) {
resulting _string = this . _input . next ( ) ;
if ( c === '/' ) { // for close tag "/>"
resulting _string += this . _input . next ( ) ;
}
token = this . _create _token ( TOKEN . TAG _CLOSE , resulting _string ) ;
} else if ( open _token . text [ 0 ] === '{' && c === '}' && this . _input . peek ( 1 ) === '}' ) {
this . _input . next ( ) ;
this . _input . next ( ) ;
token = this . _create _token ( TOKEN . TAG _CLOSE , '}}' ) ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _attribute = function ( c , previous _token , open _token ) {
var token = null ;
var resulting _string = '' ;
if ( open _token && open _token . text [ 0 ] === '<' ) {
if ( c === '=' ) {
token = this . _create _token ( TOKEN . EQUALS , this . _input . next ( ) ) ;
} else if ( c === '"' || c === "'" ) {
var content = this . _input . next ( ) ;
if ( c === '"' ) {
content += this . _ _patterns . double _quote . read ( ) ;
} else {
content += this . _ _patterns . single _quote . read ( ) ;
}
token = this . _create _token ( TOKEN . VALUE , content ) ;
} else {
resulting _string = this . _ _patterns . attribute . read ( ) ;
if ( resulting _string ) {
if ( previous _token . type === TOKEN . EQUALS ) {
token = this . _create _token ( TOKEN . VALUE , resulting _string ) ;
} else {
token = this . _create _token ( TOKEN . ATTRIBUTE , resulting _string ) ;
}
}
}
}
return token ;
} ;
Tokenizer . prototype . _is _content _unformatted = function ( tag _name ) {
// void_elements have no content and so cannot have unformatted content
// script and style tags should always be read as unformatted content
// finally content_unformatted and unformatted element contents are unformatted
return this . _options . void _elements . indexOf ( tag _name ) === - 1 &&
( this . _options . content _unformatted . indexOf ( tag _name ) !== - 1 ||
this . _options . unformatted . indexOf ( tag _name ) !== - 1 ) ;
} ;
Tokenizer . prototype . _read _raw _content = function ( c , previous _token , open _token ) { // jshint unused:false
var resulting _string = '' ;
if ( open _token && open _token . text [ 0 ] === '{' ) {
resulting _string = this . _ _patterns . handlebars _raw _close . read ( ) ;
} else if ( previous _token . type === TOKEN . TAG _CLOSE &&
previous _token . opened . text [ 0 ] === '<' && previous _token . text [ 0 ] !== '/' ) {
// ^^ empty tag has no content
var tag _name = previous _token . opened . text . substr ( 1 ) . toLowerCase ( ) ;
if ( tag _name === 'script' || tag _name === 'style' ) {
// Script and style tags are allowed to have comments wrapping their content
// or just have regular content.
var token = this . _read _comment _or _cdata ( c ) ;
if ( token ) {
token . type = TOKEN . TEXT ;
return token ;
}
resulting _string = this . _input . readUntil ( new RegExp ( '</' + tag _name + '[\\n\\r\\t ]*?>' , 'ig' ) ) ;
} else if ( this . _is _content _unformatted ( tag _name ) ) {
resulting _string = this . _input . readUntil ( new RegExp ( '</' + tag _name + '[\\n\\r\\t ]*?>' , 'ig' ) ) ;
}
}
if ( resulting _string ) {
return this . _create _token ( TOKEN . TEXT , resulting _string ) ;
}
return null ;
} ;
Tokenizer . prototype . _read _content _word = function ( c ) {
var resulting _string = '' ;
if ( this . _options . unformatted _content _delimiter ) {
if ( c === this . _options . unformatted _content _delimiter [ 0 ] ) {
resulting _string = this . _ _patterns . unformatted _content _delimiter . read ( ) ;
}
}
if ( ! resulting _string ) {
resulting _string = this . _ _patterns . word . read ( ) ;
}
if ( resulting _string ) {
return this . _create _token ( TOKEN . TEXT , resulting _string ) ;
}
} ;
module . exports . Tokenizer = Tokenizer ;
module . exports . TOKEN = TOKEN ;
/***/ } )
/******/ ] ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module used 'module' so it can't be inlined
/******/ var _ _webpack _exports _ _ = _ _webpack _require _ _ ( 0 ) ;
/******/
/******/ return _ _webpack _exports _ _ ;
/******/ } ) ( )
;
} ) ;
//# sourceMappingURL=beautifier.js.map