2021-10-01 03:17:49 -04:00
require ( './sourcemap-register.js' ) ; /******/ ( ( ) => { // webpackBootstrap
2021-10-01 00:58:11 -04:00
/******/ var _ _webpack _modules _ _ = ( {
2021-12-24 17:13:55 -05:00
/***/ 283 :
2021-10-01 03:17:49 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-01 03:17:49 -04:00
const core = _ _importStar ( _ _nccwpck _require _ _ ( 186 ) ) ;
2021-12-24 17:13:55 -05:00
const validate _1 = _ _nccwpck _require _ _ ( 751 ) ;
2021-10-01 00:58:11 -04:00
function run ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
2021-12-24 17:13:55 -05:00
const validator = new validate _1 . Validator ( {
files : core . getMultilineInput ( 'files' ) ,
schemaPath : core . getInput ( 'schemaPath' )
} ) ;
yield validator . ValidateYAML ( ) ;
2021-10-01 00:58:11 -04:00
}
catch ( error ) {
core . setFailed ( error . message ) ;
}
} ) ;
}
run ( ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 751 :
2021-10-01 03:17:49 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
2021-10-01 03:17:49 -04:00
var _ _importDefault = ( this && this . _ _importDefault ) || function ( mod ) {
return ( mod && mod . _ _esModule ) ? mod : { "default" : mod } ;
} ;
2021-10-01 00:58:11 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-12-24 17:13:55 -05:00
exports . Validator = void 0 ;
2021-10-01 03:17:49 -04:00
const yaml _validator _1 = _ _importDefault ( _ _nccwpck _require _ _ ( 551 ) ) ;
2021-12-24 17:13:55 -05:00
const fs _1 = _ _importDefault ( _ _nccwpck _require _ _ ( 147 ) ) ;
class Validator {
constructor ( props ) {
this . props = props ;
}
ValidateYAML ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return new Promise ( ( resolve , reject ) => {
const structure = fs _1 . default . readFileSync ( this . props . schemaPath , { encoding : 'utf-8' } ) ;
const validator = new yaml _validator _1 . default ( {
log : 'validator.log' ,
structure : JSON . parse ( structure ) ,
writeJson : false ,
onWarning : ( err , file ) => {
reject ( new Error ( ` File: ${ file } - ${ err . message } ` ) ) ;
} ,
} ) ;
validator . validate ( ( this . props . files ) ) ;
resolve ( validator . report ( ) ) ;
} ) ;
2021-10-01 00:58:11 -04:00
} ) ;
2021-12-24 17:13:55 -05:00
}
2021-10-01 00:58:11 -04:00
}
2021-12-24 17:13:55 -05:00
exports . Validator = Validator ;
2021-10-01 00:58:11 -04:00
/***/ } ) ,
/***/ 351 :
2021-10-01 03:17:49 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
2021-10-01 00:58:11 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
2021-10-01 03:17:49 -04:00
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
2021-10-01 00:58:11 -04:00
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-01 03:17:49 -04:00
exports . issue = exports . issueCommand = void 0 ;
2021-12-24 17:13:55 -05:00
const os = _ _importStar ( _ _nccwpck _require _ _ ( 37 ) ) ;
2021-10-01 03:17:49 -04:00
const utils _1 = _ _nccwpck _require _ _ ( 278 ) ;
2021-10-01 00:58:11 -04:00
/ * *
* Commands
*
* Command Format :
* : : name key = value , key = value : : message
*
* Examples :
* : : warning : : This is the message
* : : set - env name = MY _VAR : : some value
* /
function issueCommand ( command , properties , message ) {
const cmd = new Command ( command , properties , message ) ;
process . stdout . write ( cmd . toString ( ) + os . EOL ) ;
}
exports . issueCommand = issueCommand ;
function issue ( name , message = '' ) {
issueCommand ( name , { } , message ) ;
}
exports . issue = issue ;
const CMD _STRING = '::' ;
class Command {
constructor ( command , properties , message ) {
if ( ! command ) {
command = 'missing.command' ;
}
this . command = command ;
this . properties = properties ;
this . message = message ;
}
toString ( ) {
let cmdStr = CMD _STRING + this . command ;
if ( this . properties && Object . keys ( this . properties ) . length > 0 ) {
cmdStr += ' ' ;
let first = true ;
for ( const key in this . properties ) {
if ( this . properties . hasOwnProperty ( key ) ) {
const val = this . properties [ key ] ;
if ( val ) {
if ( first ) {
first = false ;
}
else {
cmdStr += ',' ;
}
cmdStr += ` ${ key } = ${ escapeProperty ( val ) } ` ;
}
}
}
}
cmdStr += ` ${ CMD _STRING } ${ escapeData ( this . message ) } ` ;
return cmdStr ;
}
}
function escapeData ( s ) {
return utils _1 . toCommandValue ( s )
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' ) ;
}
function escapeProperty ( s ) {
return utils _1 . toCommandValue ( s )
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' )
. replace ( /:/g , '%3A' )
. replace ( /,/g , '%2C' ) ;
}
//# sourceMappingURL=command.js.map
/***/ } ) ,
/***/ 186 :
2021-10-01 03:17:49 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
2021-10-01 00:58:11 -04:00
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-01 03:17:49 -04:00
exports . getIDToken = exports . getState = exports . saveState = exports . group = exports . endGroup = exports . startGroup = exports . info = exports . notice = exports . warning = exports . error = exports . debug = exports . isDebug = exports . setFailed = exports . setCommandEcho = exports . setOutput = exports . getBooleanInput = exports . getMultilineInput = exports . getInput = exports . addPath = exports . setSecret = exports . exportVariable = exports . ExitCode = void 0 ;
const command _1 = _ _nccwpck _require _ _ ( 351 ) ;
const file _command _1 = _ _nccwpck _require _ _ ( 717 ) ;
const utils _1 = _ _nccwpck _require _ _ ( 278 ) ;
2021-12-24 17:13:55 -05:00
const os = _ _importStar ( _ _nccwpck _require _ _ ( 37 ) ) ;
const path = _ _importStar ( _ _nccwpck _require _ _ ( 17 ) ) ;
2021-10-01 03:17:49 -04:00
const oidc _utils _1 = _ _nccwpck _require _ _ ( 41 ) ;
2021-10-01 00:58:11 -04:00
/ * *
* The code to exit an action
* /
var ExitCode ;
( function ( ExitCode ) {
/ * *
* A code indicating that the action was successful
* /
ExitCode [ ExitCode [ "Success" ] = 0 ] = "Success" ;
/ * *
* A code indicating that the action was a failure
* /
ExitCode [ ExitCode [ "Failure" ] = 1 ] = "Failure" ;
} ) ( ExitCode = exports . ExitCode || ( exports . ExitCode = { } ) ) ;
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
/ * *
* Sets env variable for this action and future actions in the job
* @ param name the name of the variable to set
* @ param val the value of the variable . Non - string values will be converted to a string via JSON . stringify
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable ( name , val ) {
const convertedVal = utils _1 . toCommandValue ( val ) ;
process . env [ name ] = convertedVal ;
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
if ( filePath ) {
const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
const commandValue = ` ${ name } << ${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
file _command _1 . issueCommand ( 'ENV' , commandValue ) ;
}
else {
command _1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
}
}
exports . exportVariable = exportVariable ;
/ * *
* Registers a secret which will get masked from logs
* @ param secret value of the secret
* /
function setSecret ( secret ) {
command _1 . issueCommand ( 'add-mask' , { } , secret ) ;
}
exports . setSecret = setSecret ;
/ * *
* Prepends inputPath to the PATH ( for this action and future actions )
* @ param inputPath
* /
function addPath ( inputPath ) {
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
if ( filePath ) {
file _command _1 . issueCommand ( 'PATH' , inputPath ) ;
}
else {
command _1 . issueCommand ( 'add-path' , { } , inputPath ) ;
}
process . env [ 'PATH' ] = ` ${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
}
exports . addPath = addPath ;
/ * *
2021-10-01 03:17:49 -04:00
* Gets the value of an input .
* Unless trimWhitespace is set to false in InputOptions , the value is also trimmed .
* Returns an empty string if the value is not defined .
2021-10-01 00:58:11 -04:00
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns string
* /
function getInput ( name , options ) {
const val = process . env [ ` INPUT_ ${ name . replace ( / /g , '_' ) . toUpperCase ( ) } ` ] || '' ;
if ( options && options . required && ! val ) {
throw new Error ( ` Input required and not supplied: ${ name } ` ) ;
}
2021-10-01 03:17:49 -04:00
if ( options && options . trimWhitespace === false ) {
return val ;
}
2021-10-01 00:58:11 -04:00
return val . trim ( ) ;
}
exports . getInput = getInput ;
2021-10-01 03:17:49 -04:00
/ * *
* Gets the values of an multiline input . Each value is also trimmed .
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns string [ ]
*
* /
function getMultilineInput ( name , options ) {
const inputs = getInput ( name , options )
. split ( '\n' )
. filter ( x => x !== '' ) ;
return inputs ;
}
exports . getMultilineInput = getMultilineInput ;
/ * *
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification .
* Support boolean input list : ` true | True | TRUE | false | False | FALSE ` .
* The return value is also in boolean type .
* ref : https : //yaml.org/spec/1.2/spec.html#id2804923
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns boolean
* /
function getBooleanInput ( name , options ) {
const trueValue = [ 'true' , 'True' , 'TRUE' ] ;
const falseValue = [ 'false' , 'False' , 'FALSE' ] ;
const val = getInput ( name , options ) ;
if ( trueValue . includes ( val ) )
return true ;
if ( falseValue . includes ( val ) )
return false ;
throw new TypeError ( ` Input does not meet YAML 1.2 "Core Schema" specification: ${ name } \n ` +
` Support boolean input list: \` true | True | TRUE | false | False | FALSE \` ` ) ;
}
exports . getBooleanInput = getBooleanInput ;
2021-10-01 00:58:11 -04:00
/ * *
* Sets the value of an output .
*
* @ param name name of the output to set
* @ param value value to store . Non - string values will be converted to a string via JSON . stringify
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput ( name , value ) {
2021-10-01 03:17:49 -04:00
process . stdout . write ( os . EOL ) ;
2021-10-01 00:58:11 -04:00
command _1 . issueCommand ( 'set-output' , { name } , value ) ;
}
exports . setOutput = setOutput ;
/ * *
* Enables or disables the echoing of commands into stdout for the rest of the step .
* Echoing is disabled by default if ACTIONS _STEP _DEBUG is not set .
*
* /
function setCommandEcho ( enabled ) {
command _1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
}
exports . setCommandEcho = setCommandEcho ;
//-----------------------------------------------------------------------
// Results
//-----------------------------------------------------------------------
/ * *
* Sets the action status to failed .
* When the action exits it will be with an exit code of 1
* @ param message add error issue message
* /
function setFailed ( message ) {
process . exitCode = ExitCode . Failure ;
error ( message ) ;
}
exports . setFailed = setFailed ;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/ * *
* Gets whether Actions Step Debug is on or not
* /
function isDebug ( ) {
return process . env [ 'RUNNER_DEBUG' ] === '1' ;
}
exports . isDebug = isDebug ;
/ * *
* Writes debug message to user log
* @ param message debug message
* /
function debug ( message ) {
command _1 . issueCommand ( 'debug' , { } , message ) ;
}
exports . debug = debug ;
/ * *
* Adds an error issue
* @ param message error issue message . Errors will be converted to string via toString ( )
2021-10-01 03:17:49 -04:00
* @ param properties optional properties to add to the annotation .
2021-10-01 00:58:11 -04:00
* /
2021-10-01 03:17:49 -04:00
function error ( message , properties = { } ) {
command _1 . issueCommand ( 'error' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2021-10-01 00:58:11 -04:00
}
exports . error = error ;
/ * *
2021-10-01 03:17:49 -04:00
* Adds a warning issue
2021-10-01 00:58:11 -04:00
* @ param message warning issue message . Errors will be converted to string via toString ( )
2021-10-01 03:17:49 -04:00
* @ param properties optional properties to add to the annotation .
2021-10-01 00:58:11 -04:00
* /
2021-10-01 03:17:49 -04:00
function warning ( message , properties = { } ) {
command _1 . issueCommand ( 'warning' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2021-10-01 00:58:11 -04:00
}
exports . warning = warning ;
2021-10-01 03:17:49 -04:00
/ * *
* Adds a notice issue
* @ param message notice issue message . Errors will be converted to string via toString ( )
* @ param properties optional properties to add to the annotation .
* /
function notice ( message , properties = { } ) {
command _1 . issueCommand ( 'notice' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
}
exports . notice = notice ;
2021-10-01 00:58:11 -04:00
/ * *
* Writes info to log with console . log .
* @ param message info message
* /
function info ( message ) {
process . stdout . write ( message + os . EOL ) ;
}
exports . info = info ;
/ * *
* Begin an output group .
*
* Output until the next ` groupEnd ` will be foldable in this group
*
* @ param name The name of the output group
* /
function startGroup ( name ) {
command _1 . issue ( 'group' , name ) ;
}
exports . startGroup = startGroup ;
/ * *
* End an output group .
* /
function endGroup ( ) {
command _1 . issue ( 'endgroup' ) ;
}
exports . endGroup = endGroup ;
/ * *
* Wrap an asynchronous function call in a group .
*
* Returns the same type as the function itself .
*
* @ param name The name of the group
* @ param fn The function to wrap in the group
* /
function group ( name , fn ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
startGroup ( name ) ;
let result ;
try {
result = yield fn ( ) ;
}
finally {
endGroup ( ) ;
}
return result ;
} ) ;
}
exports . group = group ;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/ * *
* Saves state for current action , the state can only be retrieved by this action ' s post job execution .
*
* @ param name name of the state to store
* @ param value value to store . Non - string values will be converted to a string via JSON . stringify
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState ( name , value ) {
command _1 . issueCommand ( 'save-state' , { name } , value ) ;
}
exports . saveState = saveState ;
/ * *
* Gets the value of an state set by this action ' s main execution .
*
* @ param name name of the state to get
* @ returns string
* /
function getState ( name ) {
return process . env [ ` STATE_ ${ name } ` ] || '' ;
}
exports . getState = getState ;
2021-10-01 03:17:49 -04:00
function getIDToken ( aud ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return yield oidc _utils _1 . OidcClient . getIDToken ( aud ) ;
} ) ;
}
exports . getIDToken = getIDToken ;
2021-10-01 00:58:11 -04:00
//# sourceMappingURL=core.js.map
/***/ } ) ,
/***/ 717 :
2021-10-01 03:17:49 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
// For internal use, subject to change.
2021-10-01 03:17:49 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
2021-10-01 00:58:11 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
2021-10-01 03:17:49 -04:00
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
2021-10-01 00:58:11 -04:00
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-01 03:17:49 -04:00
exports . issueCommand = void 0 ;
2021-10-01 00:58:11 -04:00
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
2021-12-24 17:13:55 -05:00
const fs = _ _importStar ( _ _nccwpck _require _ _ ( 147 ) ) ;
const os = _ _importStar ( _ _nccwpck _require _ _ ( 37 ) ) ;
2021-10-01 03:17:49 -04:00
const utils _1 = _ _nccwpck _require _ _ ( 278 ) ;
2021-10-01 00:58:11 -04:00
function issueCommand ( command , message ) {
const filePath = process . env [ ` GITHUB_ ${ command } ` ] ;
if ( ! filePath ) {
throw new Error ( ` Unable to find environment variable for file command ${ command } ` ) ;
}
if ( ! fs . existsSync ( filePath ) ) {
throw new Error ( ` Missing file at path: ${ filePath } ` ) ;
}
fs . appendFileSync ( filePath , ` ${ utils _1 . toCommandValue ( message ) } ${ os . EOL } ` , {
encoding : 'utf8'
} ) ;
}
exports . issueCommand = issueCommand ;
//# sourceMappingURL=file-command.js.map
/***/ } ) ,
2021-10-01 03:17:49 -04:00
/***/ 41 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
"use strict" ;
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . OidcClient = void 0 ;
const http _client _1 = _ _nccwpck _require _ _ ( 925 ) ;
const auth _1 = _ _nccwpck _require _ _ ( 702 ) ;
const core _1 = _ _nccwpck _require _ _ ( 186 ) ;
class OidcClient {
static createHttpClient ( allowRetry = true , maxRetry = 10 ) {
const requestOptions = {
allowRetries : allowRetry ,
maxRetries : maxRetry
} ;
return new http _client _1 . HttpClient ( 'actions/oidc-client' , [ new auth _1 . BearerCredentialHandler ( OidcClient . getRequestToken ( ) ) ] , requestOptions ) ;
}
static getRequestToken ( ) {
const token = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_TOKEN' ] ;
if ( ! token ) {
throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable' ) ;
}
return token ;
}
static getIDTokenUrl ( ) {
const runtimeUrl = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_URL' ] ;
if ( ! runtimeUrl ) {
throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable' ) ;
}
return runtimeUrl ;
}
static getCall ( id _token _url ) {
var _a ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const httpclient = OidcClient . createHttpClient ( ) ;
const res = yield httpclient
. getJson ( id _token _url )
. catch ( error => {
throw new Error ( ` Failed to get ID Token. \n
Error Code : $ { error . statusCode } \ n
Error Message : $ { error . result . message } ` );
} ) ;
const id _token = ( _a = res . result ) === null || _a === void 0 ? void 0 : _a . value ;
if ( ! id _token ) {
throw new Error ( 'Response json body do not have ID Token field' ) ;
}
return id _token ;
} ) ;
}
static getIDToken ( audience ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
// New ID Token is requested from action service
let id _token _url = OidcClient . getIDTokenUrl ( ) ;
if ( audience ) {
const encodedAudience = encodeURIComponent ( audience ) ;
id _token _url = ` ${ id _token _url } &audience= ${ encodedAudience } ` ;
}
core _1 . debug ( ` ID token url is ${ id _token _url } ` ) ;
const id _token = yield OidcClient . getCall ( id _token _url ) ;
core _1 . setSecret ( id _token ) ;
return id _token ;
}
catch ( error ) {
throw new Error ( ` Error message: ${ error . message } ` ) ;
}
} ) ;
}
}
exports . OidcClient = OidcClient ;
//# sourceMappingURL=oidc-utils.js.map
/***/ } ) ,
2021-10-01 00:58:11 -04:00
/***/ 278 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-01 03:17:49 -04:00
exports . toCommandProperties = exports . toCommandValue = void 0 ;
2021-10-01 00:58:11 -04:00
/ * *
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @ param input input to sanitize into a string
* /
function toCommandValue ( input ) {
if ( input === null || input === undefined ) {
return '' ;
}
else if ( typeof input === 'string' || input instanceof String ) {
return input ;
}
return JSON . stringify ( input ) ;
}
exports . toCommandValue = toCommandValue ;
2021-10-01 03:17:49 -04:00
/ * *
*
* @ param annotationProperties
* @ returns The command properties to send with the actual annotation command
* See IssueCommandProperties : https : //github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
* /
function toCommandProperties ( annotationProperties ) {
if ( ! Object . keys ( annotationProperties ) . length ) {
return { } ;
}
return {
title : annotationProperties . title ,
file : annotationProperties . file ,
line : annotationProperties . startLine ,
endLine : annotationProperties . endLine ,
col : annotationProperties . startColumn ,
endColumn : annotationProperties . endColumn
} ;
}
exports . toCommandProperties = toCommandProperties ;
2021-10-01 00:58:11 -04:00
//# sourceMappingURL=utils.js.map
/***/ } ) ,
2021-10-01 03:17:49 -04:00
/***/ 702 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
class BasicCredentialHandler {
constructor ( username , password ) {
this . username = username ;
this . password = password ;
}
prepareRequest ( options ) {
options . headers [ 'Authorization' ] =
'Basic ' +
Buffer . from ( this . username + ':' + this . password ) . toString ( 'base64' ) ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
exports . BasicCredentialHandler = BasicCredentialHandler ;
class BearerCredentialHandler {
constructor ( token ) {
this . token = token ;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest ( options ) {
options . headers [ 'Authorization' ] = 'Bearer ' + this . token ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
exports . BearerCredentialHandler = BearerCredentialHandler ;
class PersonalAccessTokenCredentialHandler {
constructor ( token ) {
this . token = token ;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest ( options ) {
options . headers [ 'Authorization' ] =
'Basic ' + Buffer . from ( 'PAT:' + this . token ) . toString ( 'base64' ) ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
exports . PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler ;
2021-10-01 00:58:11 -04:00
/***/ } ) ,
2021-10-01 03:17:49 -04:00
/***/ 925 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-12-24 17:13:55 -05:00
const http = _ _nccwpck _require _ _ ( 685 ) ;
const https = _ _nccwpck _require _ _ ( 687 ) ;
2021-10-01 03:17:49 -04:00
const pm = _ _nccwpck _require _ _ ( 443 ) ;
let tunnel ;
var HttpCodes ;
( function ( HttpCodes ) {
HttpCodes [ HttpCodes [ "OK" ] = 200 ] = "OK" ;
HttpCodes [ HttpCodes [ "MultipleChoices" ] = 300 ] = "MultipleChoices" ;
HttpCodes [ HttpCodes [ "MovedPermanently" ] = 301 ] = "MovedPermanently" ;
HttpCodes [ HttpCodes [ "ResourceMoved" ] = 302 ] = "ResourceMoved" ;
HttpCodes [ HttpCodes [ "SeeOther" ] = 303 ] = "SeeOther" ;
HttpCodes [ HttpCodes [ "NotModified" ] = 304 ] = "NotModified" ;
HttpCodes [ HttpCodes [ "UseProxy" ] = 305 ] = "UseProxy" ;
HttpCodes [ HttpCodes [ "SwitchProxy" ] = 306 ] = "SwitchProxy" ;
HttpCodes [ HttpCodes [ "TemporaryRedirect" ] = 307 ] = "TemporaryRedirect" ;
HttpCodes [ HttpCodes [ "PermanentRedirect" ] = 308 ] = "PermanentRedirect" ;
HttpCodes [ HttpCodes [ "BadRequest" ] = 400 ] = "BadRequest" ;
HttpCodes [ HttpCodes [ "Unauthorized" ] = 401 ] = "Unauthorized" ;
HttpCodes [ HttpCodes [ "PaymentRequired" ] = 402 ] = "PaymentRequired" ;
HttpCodes [ HttpCodes [ "Forbidden" ] = 403 ] = "Forbidden" ;
HttpCodes [ HttpCodes [ "NotFound" ] = 404 ] = "NotFound" ;
HttpCodes [ HttpCodes [ "MethodNotAllowed" ] = 405 ] = "MethodNotAllowed" ;
HttpCodes [ HttpCodes [ "NotAcceptable" ] = 406 ] = "NotAcceptable" ;
HttpCodes [ HttpCodes [ "ProxyAuthenticationRequired" ] = 407 ] = "ProxyAuthenticationRequired" ;
HttpCodes [ HttpCodes [ "RequestTimeout" ] = 408 ] = "RequestTimeout" ;
HttpCodes [ HttpCodes [ "Conflict" ] = 409 ] = "Conflict" ;
HttpCodes [ HttpCodes [ "Gone" ] = 410 ] = "Gone" ;
HttpCodes [ HttpCodes [ "TooManyRequests" ] = 429 ] = "TooManyRequests" ;
HttpCodes [ HttpCodes [ "InternalServerError" ] = 500 ] = "InternalServerError" ;
HttpCodes [ HttpCodes [ "NotImplemented" ] = 501 ] = "NotImplemented" ;
HttpCodes [ HttpCodes [ "BadGateway" ] = 502 ] = "BadGateway" ;
HttpCodes [ HttpCodes [ "ServiceUnavailable" ] = 503 ] = "ServiceUnavailable" ;
HttpCodes [ HttpCodes [ "GatewayTimeout" ] = 504 ] = "GatewayTimeout" ;
} ) ( HttpCodes = exports . HttpCodes || ( exports . HttpCodes = { } ) ) ;
var Headers ;
( function ( Headers ) {
Headers [ "Accept" ] = "accept" ;
Headers [ "ContentType" ] = "content-type" ;
} ) ( Headers = exports . Headers || ( exports . Headers = { } ) ) ;
var MediaTypes ;
( function ( MediaTypes ) {
MediaTypes [ "ApplicationJson" ] = "application/json" ;
} ) ( MediaTypes = exports . MediaTypes || ( exports . MediaTypes = { } ) ) ;
/ * *
* Returns the proxy URL , depending upon the supplied url and proxy environment variables .
* @ param serverUrl The server URL where the request will be sent . For example , https : //api.github.com
* /
function getProxyUrl ( serverUrl ) {
let proxyUrl = pm . getProxyUrl ( new URL ( serverUrl ) ) ;
return proxyUrl ? proxyUrl . href : '' ;
}
exports . getProxyUrl = getProxyUrl ;
const HttpRedirectCodes = [
HttpCodes . MovedPermanently ,
HttpCodes . ResourceMoved ,
HttpCodes . SeeOther ,
HttpCodes . TemporaryRedirect ,
HttpCodes . PermanentRedirect
] ;
const HttpResponseRetryCodes = [
HttpCodes . BadGateway ,
HttpCodes . ServiceUnavailable ,
HttpCodes . GatewayTimeout
] ;
const RetryableHttpVerbs = [ 'OPTIONS' , 'GET' , 'DELETE' , 'HEAD' ] ;
const ExponentialBackoffCeiling = 10 ;
const ExponentialBackoffTimeSlice = 5 ;
class HttpClientError extends Error {
constructor ( message , statusCode ) {
super ( message ) ;
this . name = 'HttpClientError' ;
this . statusCode = statusCode ;
Object . setPrototypeOf ( this , HttpClientError . prototype ) ;
}
}
exports . HttpClientError = HttpClientError ;
class HttpClientResponse {
constructor ( message ) {
this . message = message ;
}
readBody ( ) {
return new Promise ( async ( resolve , reject ) => {
let output = Buffer . alloc ( 0 ) ;
this . message . on ( 'data' , ( chunk ) => {
output = Buffer . concat ( [ output , chunk ] ) ;
} ) ;
this . message . on ( 'end' , ( ) => {
resolve ( output . toString ( ) ) ;
} ) ;
} ) ;
}
}
exports . HttpClientResponse = HttpClientResponse ;
function isHttps ( requestUrl ) {
let parsedUrl = new URL ( requestUrl ) ;
return parsedUrl . protocol === 'https:' ;
}
exports . isHttps = isHttps ;
class HttpClient {
constructor ( userAgent , handlers , requestOptions ) {
this . _ignoreSslError = false ;
this . _allowRedirects = true ;
this . _allowRedirectDowngrade = false ;
this . _maxRedirects = 50 ;
this . _allowRetries = false ;
this . _maxRetries = 1 ;
this . _keepAlive = false ;
this . _disposed = false ;
this . userAgent = userAgent ;
this . handlers = handlers || [ ] ;
this . requestOptions = requestOptions ;
if ( requestOptions ) {
if ( requestOptions . ignoreSslError != null ) {
this . _ignoreSslError = requestOptions . ignoreSslError ;
}
this . _socketTimeout = requestOptions . socketTimeout ;
if ( requestOptions . allowRedirects != null ) {
this . _allowRedirects = requestOptions . allowRedirects ;
}
if ( requestOptions . allowRedirectDowngrade != null ) {
this . _allowRedirectDowngrade = requestOptions . allowRedirectDowngrade ;
}
if ( requestOptions . maxRedirects != null ) {
this . _maxRedirects = Math . max ( requestOptions . maxRedirects , 0 ) ;
}
if ( requestOptions . keepAlive != null ) {
this . _keepAlive = requestOptions . keepAlive ;
}
if ( requestOptions . allowRetries != null ) {
this . _allowRetries = requestOptions . allowRetries ;
}
if ( requestOptions . maxRetries != null ) {
this . _maxRetries = requestOptions . maxRetries ;
}
}
}
options ( requestUrl , additionalHeaders ) {
return this . request ( 'OPTIONS' , requestUrl , null , additionalHeaders || { } ) ;
}
get ( requestUrl , additionalHeaders ) {
return this . request ( 'GET' , requestUrl , null , additionalHeaders || { } ) ;
}
del ( requestUrl , additionalHeaders ) {
return this . request ( 'DELETE' , requestUrl , null , additionalHeaders || { } ) ;
}
post ( requestUrl , data , additionalHeaders ) {
return this . request ( 'POST' , requestUrl , data , additionalHeaders || { } ) ;
}
patch ( requestUrl , data , additionalHeaders ) {
return this . request ( 'PATCH' , requestUrl , data , additionalHeaders || { } ) ;
}
put ( requestUrl , data , additionalHeaders ) {
return this . request ( 'PUT' , requestUrl , data , additionalHeaders || { } ) ;
}
head ( requestUrl , additionalHeaders ) {
return this . request ( 'HEAD' , requestUrl , null , additionalHeaders || { } ) ;
}
sendStream ( verb , requestUrl , stream , additionalHeaders ) {
return this . request ( verb , requestUrl , stream , additionalHeaders ) ;
}
/ * *
* Gets a typed object from an endpoint
* Be aware that not found returns a null . Other errors ( 4 xx , 5 xx ) reject the promise
* /
async getJson ( requestUrl , additionalHeaders = { } ) {
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
let res = await this . get ( requestUrl , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async postJson ( requestUrl , obj , additionalHeaders = { } ) {
let data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
let res = await this . post ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async putJson ( requestUrl , obj , additionalHeaders = { } ) {
let data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
let res = await this . put ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async patchJson ( requestUrl , obj , additionalHeaders = { } ) {
let data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
let res = await this . patch ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
/ * *
* Makes a raw http request .
* All other methods such as get , post , patch , and request ultimately call this .
* Prefer get , del , post and patch
* /
async request ( verb , requestUrl , data , headers ) {
if ( this . _disposed ) {
throw new Error ( 'Client has already been disposed.' ) ;
}
let parsedUrl = new URL ( requestUrl ) ;
let info = this . _prepareRequest ( verb , parsedUrl , headers ) ;
// Only perform retries on reads since writes may not be idempotent.
let maxTries = this . _allowRetries && RetryableHttpVerbs . indexOf ( verb ) != - 1
? this . _maxRetries + 1
: 1 ;
let numTries = 0 ;
let response ;
while ( numTries < maxTries ) {
response = await this . requestRaw ( info , data ) ;
// Check if it's an authentication challenge
if ( response &&
response . message &&
response . message . statusCode === HttpCodes . Unauthorized ) {
let authenticationHandler ;
for ( let i = 0 ; i < this . handlers . length ; i ++ ) {
if ( this . handlers [ i ] . canHandleAuthentication ( response ) ) {
authenticationHandler = this . handlers [ i ] ;
break ;
}
}
if ( authenticationHandler ) {
return authenticationHandler . handleAuthentication ( this , info , data ) ;
}
else {
// We have received an unauthorized response but have no handlers to handle it.
// Let the response return to the caller.
return response ;
}
}
let redirectsRemaining = this . _maxRedirects ;
while ( HttpRedirectCodes . indexOf ( response . message . statusCode ) != - 1 &&
this . _allowRedirects &&
redirectsRemaining > 0 ) {
const redirectUrl = response . message . headers [ 'location' ] ;
if ( ! redirectUrl ) {
// if there's no location to redirect to, we won't
break ;
}
let parsedRedirectUrl = new URL ( redirectUrl ) ;
if ( parsedUrl . protocol == 'https:' &&
parsedUrl . protocol != parsedRedirectUrl . protocol &&
! this . _allowRedirectDowngrade ) {
throw new Error ( 'Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.' ) ;
}
// we need to finish reading the response before reassigning response
// which will leak the open socket.
await response . readBody ( ) ;
// strip authorization header if redirected to a different hostname
if ( parsedRedirectUrl . hostname !== parsedUrl . hostname ) {
for ( let header in headers ) {
// header names are case insensitive
if ( header . toLowerCase ( ) === 'authorization' ) {
delete headers [ header ] ;
}
}
}
// let's make the request with the new redirectUrl
info = this . _prepareRequest ( verb , parsedRedirectUrl , headers ) ;
response = await this . requestRaw ( info , data ) ;
redirectsRemaining -- ;
}
if ( HttpResponseRetryCodes . indexOf ( response . message . statusCode ) == - 1 ) {
// If not a retry code, return immediately instead of retrying
return response ;
}
numTries += 1 ;
if ( numTries < maxTries ) {
await response . readBody ( ) ;
await this . _performExponentialBackoff ( numTries ) ;
}
}
return response ;
}
/ * *
* Needs to be called if keepAlive is set to true in request options .
* /
dispose ( ) {
if ( this . _agent ) {
this . _agent . destroy ( ) ;
}
this . _disposed = true ;
}
/ * *
* Raw request .
* @ param info
* @ param data
* /
requestRaw ( info , data ) {
return new Promise ( ( resolve , reject ) => {
let callbackForResult = function ( err , res ) {
if ( err ) {
reject ( err ) ;
}
resolve ( res ) ;
} ;
this . requestRawWithCallback ( info , data , callbackForResult ) ;
} ) ;
}
/ * *
* Raw request with callback .
* @ param info
* @ param data
* @ param onResult
* /
requestRawWithCallback ( info , data , onResult ) {
let socket ;
if ( typeof data === 'string' ) {
info . options . headers [ 'Content-Length' ] = Buffer . byteLength ( data , 'utf8' ) ;
}
let callbackCalled = false ;
let handleResult = ( err , res ) => {
if ( ! callbackCalled ) {
callbackCalled = true ;
onResult ( err , res ) ;
}
} ;
let req = info . httpModule . request ( info . options , ( msg ) => {
let res = new HttpClientResponse ( msg ) ;
handleResult ( null , res ) ;
} ) ;
req . on ( 'socket' , sock => {
socket = sock ;
} ) ;
// If we ever get disconnected, we want the socket to timeout eventually
req . setTimeout ( this . _socketTimeout || 3 * 60000 , ( ) => {
if ( socket ) {
socket . end ( ) ;
}
handleResult ( new Error ( 'Request timeout: ' + info . options . path ) , null ) ;
} ) ;
req . on ( 'error' , function ( err ) {
// err has statusCode property
// res should have headers
handleResult ( err , null ) ;
} ) ;
if ( data && typeof data === 'string' ) {
req . write ( data , 'utf8' ) ;
}
if ( data && typeof data !== 'string' ) {
data . on ( 'close' , function ( ) {
req . end ( ) ;
} ) ;
data . pipe ( req ) ;
}
else {
req . end ( ) ;
}
}
/ * *
* Gets an http agent . This function is useful when you need an http agent that handles
* routing through a proxy server - depending upon the url and proxy environment variables .
* @ param serverUrl The server URL where the request will be sent . For example , https : //api.github.com
* /
getAgent ( serverUrl ) {
let parsedUrl = new URL ( serverUrl ) ;
return this . _getAgent ( parsedUrl ) ;
}
_prepareRequest ( method , requestUrl , headers ) {
const info = { } ;
info . parsedUrl = requestUrl ;
const usingSsl = info . parsedUrl . protocol === 'https:' ;
info . httpModule = usingSsl ? https : http ;
const defaultPort = usingSsl ? 443 : 80 ;
info . options = { } ;
info . options . host = info . parsedUrl . hostname ;
info . options . port = info . parsedUrl . port
? parseInt ( info . parsedUrl . port )
: defaultPort ;
info . options . path =
( info . parsedUrl . pathname || '' ) + ( info . parsedUrl . search || '' ) ;
info . options . method = method ;
info . options . headers = this . _mergeHeaders ( headers ) ;
if ( this . userAgent != null ) {
info . options . headers [ 'user-agent' ] = this . userAgent ;
}
info . options . agent = this . _getAgent ( info . parsedUrl ) ;
// gives handlers an opportunity to participate
if ( this . handlers ) {
this . handlers . forEach ( handler => {
handler . prepareRequest ( info . options ) ;
} ) ;
}
return info ;
}
_mergeHeaders ( headers ) {
const lowercaseKeys = obj => Object . keys ( obj ) . reduce ( ( c , k ) => ( ( c [ k . toLowerCase ( ) ] = obj [ k ] ) , c ) , { } ) ;
if ( this . requestOptions && this . requestOptions . headers ) {
return Object . assign ( { } , lowercaseKeys ( this . requestOptions . headers ) , lowercaseKeys ( headers ) ) ;
}
return lowercaseKeys ( headers || { } ) ;
}
_getExistingOrDefaultHeader ( additionalHeaders , header , _default ) {
const lowercaseKeys = obj => Object . keys ( obj ) . reduce ( ( c , k ) => ( ( c [ k . toLowerCase ( ) ] = obj [ k ] ) , c ) , { } ) ;
let clientHeader ;
if ( this . requestOptions && this . requestOptions . headers ) {
clientHeader = lowercaseKeys ( this . requestOptions . headers ) [ header ] ;
}
return additionalHeaders [ header ] || clientHeader || _default ;
}
_getAgent ( parsedUrl ) {
let agent ;
let proxyUrl = pm . getProxyUrl ( parsedUrl ) ;
let useProxy = proxyUrl && proxyUrl . hostname ;
if ( this . _keepAlive && useProxy ) {
agent = this . _proxyAgent ;
}
if ( this . _keepAlive && ! useProxy ) {
agent = this . _agent ;
}
// if agent is already assigned use that agent.
if ( ! ! agent ) {
return agent ;
}
const usingSsl = parsedUrl . protocol === 'https:' ;
let maxSockets = 100 ;
if ( ! ! this . requestOptions ) {
maxSockets = this . requestOptions . maxSockets || http . globalAgent . maxSockets ;
}
if ( useProxy ) {
// If using proxy, need tunnel
if ( ! tunnel ) {
tunnel = _ _nccwpck _require _ _ ( 294 ) ;
}
const agentOptions = {
maxSockets : maxSockets ,
keepAlive : this . _keepAlive ,
proxy : {
... ( ( proxyUrl . username || proxyUrl . password ) && {
proxyAuth : ` ${ proxyUrl . username } : ${ proxyUrl . password } `
} ) ,
host : proxyUrl . hostname ,
port : proxyUrl . port
}
} ;
let tunnelAgent ;
const overHttps = proxyUrl . protocol === 'https:' ;
if ( usingSsl ) {
tunnelAgent = overHttps ? tunnel . httpsOverHttps : tunnel . httpsOverHttp ;
}
else {
tunnelAgent = overHttps ? tunnel . httpOverHttps : tunnel . httpOverHttp ;
}
agent = tunnelAgent ( agentOptions ) ;
this . _proxyAgent = agent ;
}
// if reusing agent across request and tunneling agent isn't assigned create a new agent
if ( this . _keepAlive && ! agent ) {
const options = { keepAlive : this . _keepAlive , maxSockets : maxSockets } ;
agent = usingSsl ? new https . Agent ( options ) : new http . Agent ( options ) ;
this . _agent = agent ;
}
// if not using private agent and tunnel agent isn't setup then use global agent
if ( ! agent ) {
agent = usingSsl ? https . globalAgent : http . globalAgent ;
}
if ( usingSsl && this . _ignoreSslError ) {
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
// we have to cast it to any and change it directly
agent . options = Object . assign ( agent . options || { } , {
rejectUnauthorized : false
} ) ;
}
return agent ;
}
_performExponentialBackoff ( retryNumber ) {
retryNumber = Math . min ( ExponentialBackoffCeiling , retryNumber ) ;
const ms = ExponentialBackoffTimeSlice * Math . pow ( 2 , retryNumber ) ;
return new Promise ( resolve => setTimeout ( ( ) => resolve ( ) , ms ) ) ;
}
static dateTimeDeserializer ( key , value ) {
if ( typeof value === 'string' ) {
let a = new Date ( value ) ;
if ( ! isNaN ( a . valueOf ( ) ) ) {
return a ;
}
}
return value ;
}
async _processResponse ( res , options ) {
return new Promise ( async ( resolve , reject ) => {
const statusCode = res . message . statusCode ;
const response = {
statusCode : statusCode ,
result : null ,
headers : { }
} ;
// not found leads to null obj returned
if ( statusCode == HttpCodes . NotFound ) {
resolve ( response ) ;
}
let obj ;
let contents ;
// get the result from the body
try {
contents = await res . readBody ( ) ;
if ( contents && contents . length > 0 ) {
if ( options && options . deserializeDates ) {
obj = JSON . parse ( contents , HttpClient . dateTimeDeserializer ) ;
}
else {
obj = JSON . parse ( contents ) ;
}
response . result = obj ;
}
response . headers = res . message . headers ;
}
catch ( err ) {
// Invalid resource (contents not json); leaving result obj null
}
// note that 3xx redirects are handled by the http layer.
if ( statusCode > 299 ) {
let msg ;
// if exception/error in body, attempt to get better error
if ( obj && obj . message ) {
msg = obj . message ;
}
else if ( contents && contents . length > 0 ) {
// it may be the case that the exception is in the body message as string
msg = contents ;
}
else {
msg = 'Failed request: (' + statusCode + ')' ;
}
let err = new HttpClientError ( msg , statusCode ) ;
err . result = response . result ;
reject ( err ) ;
}
else {
resolve ( response ) ;
}
} ) ;
}
}
exports . HttpClient = HttpClient ;
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
/***/ } ) ,
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
/***/ 443 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
2021-10-01 00:58:11 -04:00
2021-10-01 03:17:49 -04:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
function getProxyUrl ( reqUrl ) {
let usingSsl = reqUrl . protocol === 'https:' ;
let proxyUrl ;
if ( checkBypass ( reqUrl ) ) {
return proxyUrl ;
}
let proxyVar ;
if ( usingSsl ) {
proxyVar = process . env [ 'https_proxy' ] || process . env [ 'HTTPS_PROXY' ] ;
}
else {
proxyVar = process . env [ 'http_proxy' ] || process . env [ 'HTTP_PROXY' ] ;
}
if ( proxyVar ) {
proxyUrl = new URL ( proxyVar ) ;
}
return proxyUrl ;
}
exports . getProxyUrl = getProxyUrl ;
function checkBypass ( reqUrl ) {
if ( ! reqUrl . hostname ) {
return false ;
}
let noProxy = process . env [ 'no_proxy' ] || process . env [ 'NO_PROXY' ] || '' ;
if ( ! noProxy ) {
return false ;
}
// Determine the request port
let reqPort ;
if ( reqUrl . port ) {
reqPort = Number ( reqUrl . port ) ;
}
else if ( reqUrl . protocol === 'http:' ) {
reqPort = 80 ;
}
else if ( reqUrl . protocol === 'https:' ) {
reqPort = 443 ;
}
// Format the request hostname and hostname with port
let upperReqHosts = [ reqUrl . hostname . toUpperCase ( ) ] ;
if ( typeof reqPort === 'number' ) {
upperReqHosts . push ( ` ${ upperReqHosts [ 0 ] } : ${ reqPort } ` ) ;
}
// Compare request host against noproxy
for ( let upperNoProxyItem of noProxy
. split ( ',' )
. map ( x => x . trim ( ) . toUpperCase ( ) )
. filter ( x => x ) ) {
if ( upperReqHosts . some ( x => x === upperNoProxyItem ) ) {
return true ;
}
}
return false ;
}
exports . checkBypass = checkBypass ;
/***/ } ) ,
/***/ 34 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
/*! check-type@v0.4.11 - 2014-06-28 */
! function ( ) { "use strict" ; var a , b , c ; a = function ( _ ) { var a , b = { } ; return a = function ( c ) { var d = { } ; return d . is = function ( a ) { var d ; if ( ! _ . isString ( a ) ) throw new Error ( "Provided type is not a string" ) ; if ( d = b [ "is" + a . toLowerCase ( ) ] , ! _ . isFunction ( d ) ) throw new Error ( "Unsupported type" , a ) ; return d ( c ) } , d . is . not = function ( a ) { return ! this ( a ) } , d . has = function ( a ) { var b , d , e = ! 0 ; if ( ! _ . isString ( a ) ) throw new Error ( "Provided path is not a string" ) ; return b = a . split ( "." ) , d = c , b . forEach ( function ( a ) { e && _ . isObject ( d ) && ! _ . isUndefined ( d [ a ] ) ? d = d [ a ] : e = ! 1 } ) , e } , d . matches = function ( b ) { var d = ! 0 ; if ( ! _ . isObject ( b ) ) throw new Error ( "Provided stucture is not an object" ) ; return _ . isObject ( c ) ? ( _ . each ( b , function ( b , e ) { a ( c [ e ] ) . is . not ( b ) && ( d = ! 1 ) } ) , d ) : ! 1 } , d } , a . init = function ( a , c ) { var d , e ; return _ . isUndefined ( a ) ? ( a = _ , e = _ . without ( _ . functions ( a ) , "isEqual" ) ) : e = _ . functions ( a ) , d = _ . reduce ( e , function ( b , c ) { return b [ c ] = a [ c ] , b } , { } ) , Object . keys ( d ) . forEach ( function ( a ) { a . match ( /^is[A-Z]/ ) && ( _ . isUndefined ( b [ a . toLowerCase ( ) ] ) || c ) && ( b [ a . toLowerCase ( ) ] = d [ a ] ) } ) , this } , a . clear = function ( ) { return b = { } , this } , a } , true && ( module . exports = a ( _ _nccwpck _require _ _ ( 987 ) ) ) , "undefined" != typeof define ? define ( [ "underscore" ] , function ( _ ) { return a ( _ ) } ) : "undefined" != typeof window && ( b = a ( window . _ ) , c = function ( ) { var a = window . check ; return function ( ) { return b === window . check && ( window . check = a ) , b } } ( ) , b . noConflict = c , window . check = b ) } ( ) ;
/***/ } ) ,
/***/ 917 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var loader = _ _nccwpck _require _ _ ( 161 ) ;
var dumper = _ _nccwpck _require _ _ ( 866 ) ;
function renamed ( from , to ) {
return function ( ) {
throw new Error ( 'Function yaml.' + from + ' is removed in js-yaml 4. ' +
'Use yaml.' + to + ' instead, which is now safe by default.' ) ;
} ;
}
module . exports . Type = _ _nccwpck _require _ _ ( 73 ) ;
module . exports . Schema = _ _nccwpck _require _ _ ( 82 ) ;
module . exports . FAILSAFE _SCHEMA = _ _nccwpck _require _ _ ( 562 ) ;
module . exports . JSON _SCHEMA = _ _nccwpck _require _ _ ( 35 ) ;
module . exports . CORE _SCHEMA = _ _nccwpck _require _ _ ( 11 ) ;
module . exports . DEFAULT _SCHEMA = _ _nccwpck _require _ _ ( 759 ) ;
module . exports . load = loader . load ;
module . exports . loadAll = loader . loadAll ;
module . exports . dump = dumper . dump ;
module . exports . YAMLException = _ _nccwpck _require _ _ ( 179 ) ;
// Re-export all types in case user wants to create custom schema
module . exports . types = {
binary : _ _nccwpck _require _ _ ( 900 ) ,
float : _ _nccwpck _require _ _ ( 705 ) ,
map : _ _nccwpck _require _ _ ( 150 ) ,
null : _ _nccwpck _require _ _ ( 721 ) ,
pairs : _ _nccwpck _require _ _ ( 860 ) ,
set : _ _nccwpck _require _ _ ( 548 ) ,
timestamp : _ _nccwpck _require _ _ ( 212 ) ,
bool : _ _nccwpck _require _ _ ( 993 ) ,
int : _ _nccwpck _require _ _ ( 615 ) ,
merge : _ _nccwpck _require _ _ ( 104 ) ,
omap : _ _nccwpck _require _ _ ( 46 ) ,
2021-12-24 17:13:55 -05:00
seq : _ _nccwpck _require _ _ ( 546 ) ,
2021-10-01 03:17:49 -04:00
str : _ _nccwpck _require _ _ ( 619 )
} ;
// Removed functions from JS-YAML 3.0.x
module . exports . safeLoad = renamed ( 'safeLoad' , 'load' ) ;
module . exports . safeLoadAll = renamed ( 'safeLoadAll' , 'loadAll' ) ;
module . exports . safeDump = renamed ( 'safeDump' , 'dump' ) ;
/***/ } ) ,
/***/ 829 :
/***/ ( ( module ) => {
"use strict" ;
function isNothing ( subject ) {
return ( typeof subject === 'undefined' ) || ( subject === null ) ;
}
function isObject ( subject ) {
return ( typeof subject === 'object' ) && ( subject !== null ) ;
}
function toArray ( sequence ) {
if ( Array . isArray ( sequence ) ) return sequence ;
else if ( isNothing ( sequence ) ) return [ ] ;
return [ sequence ] ;
}
function extend ( target , source ) {
var index , length , key , sourceKeys ;
if ( source ) {
sourceKeys = Object . keys ( source ) ;
for ( index = 0 , length = sourceKeys . length ; index < length ; index += 1 ) {
key = sourceKeys [ index ] ;
target [ key ] = source [ key ] ;
}
}
return target ;
}
function repeat ( string , count ) {
var result = '' , cycle ;
for ( cycle = 0 ; cycle < count ; cycle += 1 ) {
result += string ;
}
return result ;
}
function isNegativeZero ( number ) {
return ( number === 0 ) && ( Number . NEGATIVE _INFINITY === 1 / number ) ;
}
module . exports . isNothing = isNothing ;
module . exports . isObject = isObject ;
module . exports . toArray = toArray ;
module . exports . repeat = repeat ;
module . exports . isNegativeZero = isNegativeZero ;
module . exports . extend = extend ;
/***/ } ) ,
/***/ 866 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
/*eslint-disable no-use-before-define*/
var common = _ _nccwpck _require _ _ ( 829 ) ;
var YAMLException = _ _nccwpck _require _ _ ( 179 ) ;
var DEFAULT _SCHEMA = _ _nccwpck _require _ _ ( 759 ) ;
var _toString = Object . prototype . toString ;
var _hasOwnProperty = Object . prototype . hasOwnProperty ;
var CHAR _BOM = 0xFEFF ;
var CHAR _TAB = 0x09 ; /* Tab */
var CHAR _LINE _FEED = 0x0A ; /* LF */
var CHAR _CARRIAGE _RETURN = 0x0D ; /* CR */
var CHAR _SPACE = 0x20 ; /* Space */
var CHAR _EXCLAMATION = 0x21 ; /* ! */
var CHAR _DOUBLE _QUOTE = 0x22 ; /* " */
var CHAR _SHARP = 0x23 ; /* # */
var CHAR _PERCENT = 0x25 ; /* % */
var CHAR _AMPERSAND = 0x26 ; /* & */
var CHAR _SINGLE _QUOTE = 0x27 ; /* ' */
var CHAR _ASTERISK = 0x2A ; /* * */
var CHAR _COMMA = 0x2C ; /* , */
var CHAR _MINUS = 0x2D ; /* - */
var CHAR _COLON = 0x3A ; /* : */
var CHAR _EQUALS = 0x3D ; /* = */
var CHAR _GREATER _THAN = 0x3E ; /* > */
var CHAR _QUESTION = 0x3F ; /* ? */
var CHAR _COMMERCIAL _AT = 0x40 ; /* @ */
var CHAR _LEFT _SQUARE _BRACKET = 0x5B ; /* [ */
var CHAR _RIGHT _SQUARE _BRACKET = 0x5D ; /* ] */
var CHAR _GRAVE _ACCENT = 0x60 ; /* ` */
var CHAR _LEFT _CURLY _BRACKET = 0x7B ; /* { */
var CHAR _VERTICAL _LINE = 0x7C ; /* | */
var CHAR _RIGHT _CURLY _BRACKET = 0x7D ; /* } */
var ESCAPE _SEQUENCES = { } ;
ESCAPE _SEQUENCES [ 0x00 ] = '\\0' ;
ESCAPE _SEQUENCES [ 0x07 ] = '\\a' ;
ESCAPE _SEQUENCES [ 0x08 ] = '\\b' ;
ESCAPE _SEQUENCES [ 0x09 ] = '\\t' ;
ESCAPE _SEQUENCES [ 0x0A ] = '\\n' ;
ESCAPE _SEQUENCES [ 0x0B ] = '\\v' ;
ESCAPE _SEQUENCES [ 0x0C ] = '\\f' ;
ESCAPE _SEQUENCES [ 0x0D ] = '\\r' ;
ESCAPE _SEQUENCES [ 0x1B ] = '\\e' ;
ESCAPE _SEQUENCES [ 0x22 ] = '\\"' ;
ESCAPE _SEQUENCES [ 0x5C ] = '\\\\' ;
ESCAPE _SEQUENCES [ 0x85 ] = '\\N' ;
ESCAPE _SEQUENCES [ 0xA0 ] = '\\_' ;
ESCAPE _SEQUENCES [ 0x2028 ] = '\\L' ;
ESCAPE _SEQUENCES [ 0x2029 ] = '\\P' ;
var DEPRECATED _BOOLEANS _SYNTAX = [
'y' , 'Y' , 'yes' , 'Yes' , 'YES' , 'on' , 'On' , 'ON' ,
'n' , 'N' , 'no' , 'No' , 'NO' , 'off' , 'Off' , 'OFF'
] ;
var DEPRECATED _BASE60 _SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/ ;
function compileStyleMap ( schema , map ) {
var result , keys , index , length , tag , style , type ;
if ( map === null ) return { } ;
result = { } ;
keys = Object . keys ( map ) ;
for ( index = 0 , length = keys . length ; index < length ; index += 1 ) {
tag = keys [ index ] ;
style = String ( map [ tag ] ) ;
if ( tag . slice ( 0 , 2 ) === '!!' ) {
tag = 'tag:yaml.org,2002:' + tag . slice ( 2 ) ;
}
type = schema . compiledTypeMap [ 'fallback' ] [ tag ] ;
if ( type && _hasOwnProperty . call ( type . styleAliases , style ) ) {
style = type . styleAliases [ style ] ;
}
result [ tag ] = style ;
}
return result ;
}
function encodeHex ( character ) {
var string , handle , length ;
string = character . toString ( 16 ) . toUpperCase ( ) ;
if ( character <= 0xFF ) {
handle = 'x' ;
length = 2 ;
} else if ( character <= 0xFFFF ) {
handle = 'u' ;
length = 4 ;
} else if ( character <= 0xFFFFFFFF ) {
handle = 'U' ;
length = 8 ;
} else {
throw new YAMLException ( 'code point within a string may not be greater than 0xFFFFFFFF' ) ;
}
return '\\' + handle + common . repeat ( '0' , length - string . length ) + string ;
}
var QUOTING _TYPE _SINGLE = 1 ,
QUOTING _TYPE _DOUBLE = 2 ;
function State ( options ) {
this . schema = options [ 'schema' ] || DEFAULT _SCHEMA ;
this . indent = Math . max ( 1 , ( options [ 'indent' ] || 2 ) ) ;
this . noArrayIndent = options [ 'noArrayIndent' ] || false ;
this . skipInvalid = options [ 'skipInvalid' ] || false ;
this . flowLevel = ( common . isNothing ( options [ 'flowLevel' ] ) ? - 1 : options [ 'flowLevel' ] ) ;
this . styleMap = compileStyleMap ( this . schema , options [ 'styles' ] || null ) ;
this . sortKeys = options [ 'sortKeys' ] || false ;
this . lineWidth = options [ 'lineWidth' ] || 80 ;
this . noRefs = options [ 'noRefs' ] || false ;
this . noCompatMode = options [ 'noCompatMode' ] || false ;
this . condenseFlow = options [ 'condenseFlow' ] || false ;
this . quotingType = options [ 'quotingType' ] === '"' ? QUOTING _TYPE _DOUBLE : QUOTING _TYPE _SINGLE ;
this . forceQuotes = options [ 'forceQuotes' ] || false ;
this . replacer = typeof options [ 'replacer' ] === 'function' ? options [ 'replacer' ] : null ;
this . implicitTypes = this . schema . compiledImplicit ;
this . explicitTypes = this . schema . compiledExplicit ;
this . tag = null ;
this . result = '' ;
this . duplicates = [ ] ;
this . usedDuplicates = null ;
}
// Indents every line in a string. Empty lines (\n only) are not indented.
function indentString ( string , spaces ) {
var ind = common . repeat ( ' ' , spaces ) ,
position = 0 ,
next = - 1 ,
result = '' ,
line ,
length = string . length ;
while ( position < length ) {
next = string . indexOf ( '\n' , position ) ;
if ( next === - 1 ) {
line = string . slice ( position ) ;
position = length ;
} else {
line = string . slice ( position , next + 1 ) ;
position = next + 1 ;
}
if ( line . length && line !== '\n' ) result += ind ;
result += line ;
}
return result ;
}
function generateNextLine ( state , level ) {
return '\n' + common . repeat ( ' ' , state . indent * level ) ;
}
function testImplicitResolving ( state , str ) {
var index , length , type ;
for ( index = 0 , length = state . implicitTypes . length ; index < length ; index += 1 ) {
type = state . implicitTypes [ index ] ;
if ( type . resolve ( str ) ) {
return true ;
}
}
return false ;
}
// [33] s-white ::= s-space | s-tab
function isWhitespace ( c ) {
return c === CHAR _SPACE || c === CHAR _TAB ;
}
// Returns true if the character can be printed without escaping.
// From YAML 1.2: "any allowed characters known to be non-printable
// should also be escaped. [However,] This isn’ t mandatory"
// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
function isPrintable ( c ) {
return ( 0x00020 <= c && c <= 0x00007E )
|| ( ( 0x000A1 <= c && c <= 0x00D7FF ) && c !== 0x2028 && c !== 0x2029 )
|| ( ( 0x0E000 <= c && c <= 0x00FFFD ) && c !== CHAR _BOM )
|| ( 0x10000 <= c && c <= 0x10FFFF ) ;
}
// [34] ns-char ::= nb-char - s-white
// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
// [26] b-char ::= b-line-feed | b-carriage-return
// Including s-white (for some reason, examples doesn't match specs in this aspect)
// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark
function isNsCharOrWhitespace ( c ) {
return isPrintable ( c )
&& c !== CHAR _BOM
// - b-char
&& c !== CHAR _CARRIAGE _RETURN
&& c !== CHAR _LINE _FEED ;
}
// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out
// c = flow-in ⇒ ns-plain-safe-in
// c = block-key ⇒ ns-plain-safe-out
// c = flow-key ⇒ ns-plain-safe-in
// [128] ns-plain-safe-out ::= ns-char
// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator
// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” )
// | ( /* An ns-char preceding */ “#” )
// | ( “:” /* Followed by an ns-plain-safe(c) */ )
function isPlainSafe ( c , prev , inblock ) {
var cIsNsCharOrWhitespace = isNsCharOrWhitespace ( c ) ;
var cIsNsChar = cIsNsCharOrWhitespace && ! isWhitespace ( c ) ;
return (
// ns-plain-safe
inblock ? // c = flow-in
cIsNsCharOrWhitespace
: cIsNsCharOrWhitespace
// - c-flow-indicator
&& c !== CHAR _COMMA
&& c !== CHAR _LEFT _SQUARE _BRACKET
&& c !== CHAR _RIGHT _SQUARE _BRACKET
&& c !== CHAR _LEFT _CURLY _BRACKET
&& c !== CHAR _RIGHT _CURLY _BRACKET
)
// ns-plain-char
&& c !== CHAR _SHARP // false on '#'
&& ! ( prev === CHAR _COLON && ! cIsNsChar ) // false on ': '
|| ( isNsCharOrWhitespace ( prev ) && ! isWhitespace ( prev ) && c === CHAR _SHARP ) // change to true on '[^ ]#'
|| ( prev === CHAR _COLON && cIsNsChar ) ; // change to true on ':[^ ]'
}
// Simplified test for values allowed as the first character in plain style.
function isPlainSafeFirst ( c ) {
// Uses a subset of ns-char - c-indicator
// where ns-char = nb-char - s-white.
// No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part
return isPrintable ( c ) && c !== CHAR _BOM
&& ! isWhitespace ( c ) // - s-white
// - (c-indicator ::=
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
&& c !== CHAR _MINUS
&& c !== CHAR _QUESTION
&& c !== CHAR _COLON
&& c !== CHAR _COMMA
&& c !== CHAR _LEFT _SQUARE _BRACKET
&& c !== CHAR _RIGHT _SQUARE _BRACKET
&& c !== CHAR _LEFT _CURLY _BRACKET
&& c !== CHAR _RIGHT _CURLY _BRACKET
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
&& c !== CHAR _SHARP
&& c !== CHAR _AMPERSAND
&& c !== CHAR _ASTERISK
&& c !== CHAR _EXCLAMATION
&& c !== CHAR _VERTICAL _LINE
&& c !== CHAR _EQUALS
&& c !== CHAR _GREATER _THAN
&& c !== CHAR _SINGLE _QUOTE
&& c !== CHAR _DOUBLE _QUOTE
// | “%” | “@” | “`”)
&& c !== CHAR _PERCENT
&& c !== CHAR _COMMERCIAL _AT
&& c !== CHAR _GRAVE _ACCENT ;
}
// Simplified test for values allowed as the last character in plain style.
function isPlainSafeLast ( c ) {
// just not whitespace or colon, it will be checked to be plain character later
return ! isWhitespace ( c ) && c !== CHAR _COLON ;
}
// Same as 'string'.codePointAt(pos), but works in older browsers.
function codePointAt ( string , pos ) {
var first = string . charCodeAt ( pos ) , second ;
if ( first >= 0xD800 && first <= 0xDBFF && pos + 1 < string . length ) {
second = string . charCodeAt ( pos + 1 ) ;
if ( second >= 0xDC00 && second <= 0xDFFF ) {
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
return ( first - 0xD800 ) * 0x400 + second - 0xDC00 + 0x10000 ;
}
}
return first ;
}
// Determines whether block indentation indicator is required.
function needIndentIndicator ( string ) {
var leadingSpaceRe = /^\n* / ;
return leadingSpaceRe . test ( string ) ;
}
var STYLE _PLAIN = 1 ,
STYLE _SINGLE = 2 ,
STYLE _LITERAL = 3 ,
STYLE _FOLDED = 4 ,
STYLE _DOUBLE = 5 ;
// Determines which scalar styles are possible and returns the preferred style.
// lineWidth = -1 => no limit.
// Pre-conditions: str.length > 0.
// Post-conditions:
// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
function chooseScalarStyle ( string , singleLineOnly , indentPerLevel , lineWidth ,
testAmbiguousType , quotingType , forceQuotes , inblock ) {
var i ;
var char = 0 ;
var prevChar = null ;
var hasLineBreak = false ;
var hasFoldableLine = false ; // only checked if shouldTrackWidth
var shouldTrackWidth = lineWidth !== - 1 ;
var previousLineBreak = - 1 ; // count the first line correctly
var plain = isPlainSafeFirst ( codePointAt ( string , 0 ) )
&& isPlainSafeLast ( codePointAt ( string , string . length - 1 ) ) ;
if ( singleLineOnly || forceQuotes ) {
// Case: no block styles.
// Check for disallowed characters to rule out plain and single.
for ( i = 0 ; i < string . length ; char >= 0x10000 ? i += 2 : i ++ ) {
char = codePointAt ( string , i ) ;
if ( ! isPrintable ( char ) ) {
return STYLE _DOUBLE ;
}
plain = plain && isPlainSafe ( char , prevChar , inblock ) ;
prevChar = char ;
}
} else {
// Case: block styles permitted.
for ( i = 0 ; i < string . length ; char >= 0x10000 ? i += 2 : i ++ ) {
char = codePointAt ( string , i ) ;
if ( char === CHAR _LINE _FEED ) {
hasLineBreak = true ;
// Check if any line can be folded.
if ( shouldTrackWidth ) {
hasFoldableLine = hasFoldableLine ||
// Foldable line = too long, and not more-indented.
( i - previousLineBreak - 1 > lineWidth &&
string [ previousLineBreak + 1 ] !== ' ' ) ;
previousLineBreak = i ;
}
} else if ( ! isPrintable ( char ) ) {
return STYLE _DOUBLE ;
}
plain = plain && isPlainSafe ( char , prevChar , inblock ) ;
prevChar = char ;
}
// in case the end is missing a \n
hasFoldableLine = hasFoldableLine || ( shouldTrackWidth &&
( i - previousLineBreak - 1 > lineWidth &&
string [ previousLineBreak + 1 ] !== ' ' ) ) ;
}
// Although every style can represent \n without escaping, prefer block styles
// for multiline, since they're more readable and they don't add empty lines.
// Also prefer folding a super-long line.
if ( ! hasLineBreak && ! hasFoldableLine ) {
// Strings interpretable as another type have to be quoted;
// e.g. the string 'true' vs. the boolean true.
if ( plain && ! forceQuotes && ! testAmbiguousType ( string ) ) {
return STYLE _PLAIN ;
}
return quotingType === QUOTING _TYPE _DOUBLE ? STYLE _DOUBLE : STYLE _SINGLE ;
}
// Edge case: block indentation indicator can only have one digit.
if ( indentPerLevel > 9 && needIndentIndicator ( string ) ) {
return STYLE _DOUBLE ;
}
// At this point we know block styles are valid.
// Prefer literal style unless we want to fold.
if ( ! forceQuotes ) {
return hasFoldableLine ? STYLE _FOLDED : STYLE _LITERAL ;
}
return quotingType === QUOTING _TYPE _DOUBLE ? STYLE _DOUBLE : STYLE _SINGLE ;
}
// Note: line breaking/folding is implemented for only the folded style.
// NB. We drop the last trailing newline (if any) of a returned block scalar
// since the dumper adds its own newline. This always works:
// • No ending newline => unaffected; already using strip "-" chomping.
// • Ending newline => removed then restored.
// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
function writeScalar ( state , string , level , iskey , inblock ) {
state . dump = ( function ( ) {
if ( string . length === 0 ) {
return state . quotingType === QUOTING _TYPE _DOUBLE ? '""' : "''" ;
}
if ( ! state . noCompatMode ) {
if ( DEPRECATED _BOOLEANS _SYNTAX . indexOf ( string ) !== - 1 || DEPRECATED _BASE60 _SYNTAX . test ( string ) ) {
return state . quotingType === QUOTING _TYPE _DOUBLE ? ( '"' + string + '"' ) : ( "'" + string + "'" ) ;
}
}
var indent = state . indent * Math . max ( 1 , level ) ; // no 0-indent scalars
// As indentation gets deeper, let the width decrease monotonically
// to the lower bound min(state.lineWidth, 40).
// Note that this implies
// state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
// state.lineWidth > 40 + state.indent: width decreases until the lower bound.
// This behaves better than a constant minimum width which disallows narrower options,
// or an indent threshold which causes the width to suddenly increase.
var lineWidth = state . lineWidth === - 1
? - 1 : Math . max ( Math . min ( state . lineWidth , 40 ) , state . lineWidth - indent ) ;
// Without knowing if keys are implicit/explicit, assume implicit for safety.
var singleLineOnly = iskey
// No block styles in flow mode.
|| ( state . flowLevel > - 1 && level >= state . flowLevel ) ;
function testAmbiguity ( string ) {
return testImplicitResolving ( state , string ) ;
}
switch ( chooseScalarStyle ( string , singleLineOnly , state . indent , lineWidth ,
testAmbiguity , state . quotingType , state . forceQuotes && ! iskey , inblock ) ) {
case STYLE _PLAIN :
return string ;
case STYLE _SINGLE :
return "'" + string . replace ( /'/g , "''" ) + "'" ;
case STYLE _LITERAL :
return '|' + blockHeader ( string , state . indent )
+ dropEndingNewline ( indentString ( string , indent ) ) ;
case STYLE _FOLDED :
return '>' + blockHeader ( string , state . indent )
+ dropEndingNewline ( indentString ( foldString ( string , lineWidth ) , indent ) ) ;
case STYLE _DOUBLE :
return '"' + escapeString ( string , lineWidth ) + '"' ;
default :
throw new YAMLException ( 'impossible error: invalid scalar style' ) ;
}
} ( ) ) ;
}
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
function blockHeader ( string , indentPerLevel ) {
var indentIndicator = needIndentIndicator ( string ) ? String ( indentPerLevel ) : '' ;
// note the special case: the string '\n' counts as a "trailing" empty line.
var clip = string [ string . length - 1 ] === '\n' ;
var keep = clip && ( string [ string . length - 2 ] === '\n' || string === '\n' ) ;
var chomp = keep ? '+' : ( clip ? '' : '-' ) ;
return indentIndicator + chomp + '\n' ;
}
// (See the note for writeScalar.)
function dropEndingNewline ( string ) {
return string [ string . length - 1 ] === '\n' ? string . slice ( 0 , - 1 ) : string ;
}
// Note: a long line without a suitable break point will exceed the width limit.
// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
function foldString ( string , width ) {
// In folded style, $k$ consecutive newlines output as $k+1$ newlines—
// unless they're before or after a more-indented line, or at the very
// beginning or end, in which case $k$ maps to $k$.
// Therefore, parse each chunk as newline(s) followed by a content line.
var lineRe = /(\n+)([^\n]*)/g ;
// first line (possibly an empty line)
var result = ( function ( ) {
var nextLF = string . indexOf ( '\n' ) ;
nextLF = nextLF !== - 1 ? nextLF : string . length ;
lineRe . lastIndex = nextLF ;
return foldLine ( string . slice ( 0 , nextLF ) , width ) ;
} ( ) ) ;
// If we haven't reached the first content line yet, don't add an extra \n.
var prevMoreIndented = string [ 0 ] === '\n' || string [ 0 ] === ' ' ;
var moreIndented ;
// rest of the lines
var match ;
while ( ( match = lineRe . exec ( string ) ) ) {
var prefix = match [ 1 ] , line = match [ 2 ] ;
moreIndented = ( line [ 0 ] === ' ' ) ;
result += prefix
+ ( ! prevMoreIndented && ! moreIndented && line !== ''
? '\n' : '' )
+ foldLine ( line , width ) ;
prevMoreIndented = moreIndented ;
}
return result ;
}
// Greedy line breaking.
// Picks the longest line under the limit each time,
// otherwise settles for the shortest line over the limit.
// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
function foldLine ( line , width ) {
if ( line === '' || line [ 0 ] === ' ' ) return line ;
// Since a more-indented line adds a \n, breaks can't be followed by a space.
var breakRe = / [^ ]/g ; // note: the match index will always be <= length-2.
var match ;
// start is an inclusive index. end, curr, and next are exclusive.
var start = 0 , end , curr = 0 , next = 0 ;
var result = '' ;
// Invariants: 0 <= start <= length-1.
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
// Inside the loop:
// A match implies length >= 2, so curr and next are <= length-2.
while ( ( match = breakRe . exec ( line ) ) ) {
next = match . index ;
// maintain invariant: curr - start <= width
if ( next - start > width ) {
end = ( curr > start ) ? curr : next ; // derive end <= length-2
result += '\n' + line . slice ( start , end ) ;
// skip the space that was output as \n
start = end + 1 ; // derive start <= length-1
}
curr = next ;
}
// By the invariants, start <= length-1, so there is something left over.
// It is either the whole string or a part starting from non-whitespace.
result += '\n' ;
// Insert a break if the remainder is too long and there is a break available.
if ( line . length - start > width && curr > start ) {
result += line . slice ( start , curr ) + '\n' + line . slice ( curr + 1 ) ;
} else {
result += line . slice ( start ) ;
}
return result . slice ( 1 ) ; // drop extra \n joiner
}
// Escapes a double-quoted string.
function escapeString ( string ) {
var result = '' ;
var char = 0 ;
var escapeSeq ;
for ( var i = 0 ; i < string . length ; char >= 0x10000 ? i += 2 : i ++ ) {
char = codePointAt ( string , i ) ;
escapeSeq = ESCAPE _SEQUENCES [ char ] ;
if ( ! escapeSeq && isPrintable ( char ) ) {
result += string [ i ] ;
if ( char >= 0x10000 ) result += string [ i + 1 ] ;
} else {
result += escapeSeq || encodeHex ( char ) ;
}
}
return result ;
}
function writeFlowSequence ( state , level , object ) {
var _result = '' ,
_tag = state . tag ,
index ,
length ,
value ;
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
value = object [ index ] ;
if ( state . replacer ) {
value = state . replacer . call ( object , String ( index ) , value ) ;
}
// Write only valid elements, put null instead of invalid elements.
if ( writeNode ( state , level , value , false , false ) ||
( typeof value === 'undefined' &&
writeNode ( state , level , null , false , false ) ) ) {
if ( _result !== '' ) _result += ',' + ( ! state . condenseFlow ? ' ' : '' ) ;
_result += state . dump ;
}
}
state . tag = _tag ;
state . dump = '[' + _result + ']' ;
}
function writeBlockSequence ( state , level , object , compact ) {
var _result = '' ,
_tag = state . tag ,
index ,
length ,
value ;
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
value = object [ index ] ;
if ( state . replacer ) {
value = state . replacer . call ( object , String ( index ) , value ) ;
}
// Write only valid elements, put null instead of invalid elements.
if ( writeNode ( state , level + 1 , value , true , true , false , true ) ||
( typeof value === 'undefined' &&
writeNode ( state , level + 1 , null , true , true , false , true ) ) ) {
if ( ! compact || _result !== '' ) {
_result += generateNextLine ( state , level ) ;
}
if ( state . dump && CHAR _LINE _FEED === state . dump . charCodeAt ( 0 ) ) {
_result += '-' ;
} else {
_result += '- ' ;
}
_result += state . dump ;
}
}
state . tag = _tag ;
state . dump = _result || '[]' ; // Empty sequence if no valid values.
}
function writeFlowMapping ( state , level , object ) {
var _result = '' ,
_tag = state . tag ,
objectKeyList = Object . keys ( object ) ,
index ,
length ,
objectKey ,
objectValue ,
pairBuffer ;
for ( index = 0 , length = objectKeyList . length ; index < length ; index += 1 ) {
pairBuffer = '' ;
if ( _result !== '' ) pairBuffer += ', ' ;
if ( state . condenseFlow ) pairBuffer += '"' ;
objectKey = objectKeyList [ index ] ;
objectValue = object [ objectKey ] ;
if ( state . replacer ) {
objectValue = state . replacer . call ( object , objectKey , objectValue ) ;
}
if ( ! writeNode ( state , level , objectKey , false , false ) ) {
continue ; // Skip this pair because of invalid key;
}
if ( state . dump . length > 1024 ) pairBuffer += '? ' ;
pairBuffer += state . dump + ( state . condenseFlow ? '"' : '' ) + ':' + ( state . condenseFlow ? '' : ' ' ) ;
if ( ! writeNode ( state , level , objectValue , false , false ) ) {
continue ; // Skip this pair because of invalid value.
}
pairBuffer += state . dump ;
// Both key and value are valid.
_result += pairBuffer ;
}
state . tag = _tag ;
state . dump = '{' + _result + '}' ;
}
function writeBlockMapping ( state , level , object , compact ) {
var _result = '' ,
_tag = state . tag ,
objectKeyList = Object . keys ( object ) ,
index ,
length ,
objectKey ,
objectValue ,
explicitPair ,
pairBuffer ;
// Allow sorting keys so that the output file is deterministic
if ( state . sortKeys === true ) {
// Default sorting
objectKeyList . sort ( ) ;
} else if ( typeof state . sortKeys === 'function' ) {
// Custom sort function
objectKeyList . sort ( state . sortKeys ) ;
} else if ( state . sortKeys ) {
// Something is wrong
throw new YAMLException ( 'sortKeys must be a boolean or a function' ) ;
}
for ( index = 0 , length = objectKeyList . length ; index < length ; index += 1 ) {
pairBuffer = '' ;
if ( ! compact || _result !== '' ) {
pairBuffer += generateNextLine ( state , level ) ;
}
objectKey = objectKeyList [ index ] ;
objectValue = object [ objectKey ] ;
if ( state . replacer ) {
objectValue = state . replacer . call ( object , objectKey , objectValue ) ;
}
if ( ! writeNode ( state , level + 1 , objectKey , true , true , true ) ) {
continue ; // Skip this pair because of invalid key.
}
explicitPair = ( state . tag !== null && state . tag !== '?' ) ||
( state . dump && state . dump . length > 1024 ) ;
if ( explicitPair ) {
if ( state . dump && CHAR _LINE _FEED === state . dump . charCodeAt ( 0 ) ) {
pairBuffer += '?' ;
} else {
pairBuffer += '? ' ;
}
}
pairBuffer += state . dump ;
if ( explicitPair ) {
pairBuffer += generateNextLine ( state , level ) ;
}
if ( ! writeNode ( state , level + 1 , objectValue , true , explicitPair ) ) {
continue ; // Skip this pair because of invalid value.
}
if ( state . dump && CHAR _LINE _FEED === state . dump . charCodeAt ( 0 ) ) {
pairBuffer += ':' ;
} else {
pairBuffer += ': ' ;
}
pairBuffer += state . dump ;
// Both key and value are valid.
_result += pairBuffer ;
}
state . tag = _tag ;
state . dump = _result || '{}' ; // Empty mapping if no valid pairs.
}
function detectType ( state , object , explicit ) {
var _result , typeList , index , length , type , style ;
typeList = explicit ? state . explicitTypes : state . implicitTypes ;
for ( index = 0 , length = typeList . length ; index < length ; index += 1 ) {
type = typeList [ index ] ;
if ( ( type . instanceOf || type . predicate ) &&
( ! type . instanceOf || ( ( typeof object === 'object' ) && ( object instanceof type . instanceOf ) ) ) &&
( ! type . predicate || type . predicate ( object ) ) ) {
if ( explicit ) {
if ( type . multi && type . representName ) {
state . tag = type . representName ( object ) ;
} else {
state . tag = type . tag ;
}
} else {
state . tag = '?' ;
}
if ( type . represent ) {
style = state . styleMap [ type . tag ] || type . defaultStyle ;
if ( _toString . call ( type . represent ) === '[object Function]' ) {
_result = type . represent ( object , style ) ;
} else if ( _hasOwnProperty . call ( type . represent , style ) ) {
_result = type . represent [ style ] ( object , style ) ;
} else {
throw new YAMLException ( '!<' + type . tag + '> tag resolver accepts not "' + style + '" style' ) ;
}
state . dump = _result ;
}
return true ;
}
}
return false ;
}
// Serializes `object` and writes it to global `result`.
// Returns true on success, or false on invalid object.
//
function writeNode ( state , level , object , block , compact , iskey , isblockseq ) {
state . tag = null ;
state . dump = object ;
if ( ! detectType ( state , object , false ) ) {
detectType ( state , object , true ) ;
}
var type = _toString . call ( state . dump ) ;
var inblock = block ;
var tagStr ;
if ( block ) {
block = ( state . flowLevel < 0 || state . flowLevel > level ) ;
}
var objectOrArray = type === '[object Object]' || type === '[object Array]' ,
duplicateIndex ,
duplicate ;
if ( objectOrArray ) {
duplicateIndex = state . duplicates . indexOf ( object ) ;
duplicate = duplicateIndex !== - 1 ;
}
if ( ( state . tag !== null && state . tag !== '?' ) || duplicate || ( state . indent !== 2 && level > 0 ) ) {
compact = false ;
}
if ( duplicate && state . usedDuplicates [ duplicateIndex ] ) {
state . dump = '*ref_' + duplicateIndex ;
} else {
if ( objectOrArray && duplicate && ! state . usedDuplicates [ duplicateIndex ] ) {
state . usedDuplicates [ duplicateIndex ] = true ;
}
if ( type === '[object Object]' ) {
if ( block && ( Object . keys ( state . dump ) . length !== 0 ) ) {
writeBlockMapping ( state , level , state . dump , compact ) ;
if ( duplicate ) {
state . dump = '&ref_' + duplicateIndex + state . dump ;
}
} else {
writeFlowMapping ( state , level , state . dump ) ;
if ( duplicate ) {
state . dump = '&ref_' + duplicateIndex + ' ' + state . dump ;
}
}
} else if ( type === '[object Array]' ) {
if ( block && ( state . dump . length !== 0 ) ) {
if ( state . noArrayIndent && ! isblockseq && level > 0 ) {
writeBlockSequence ( state , level - 1 , state . dump , compact ) ;
} else {
writeBlockSequence ( state , level , state . dump , compact ) ;
}
if ( duplicate ) {
state . dump = '&ref_' + duplicateIndex + state . dump ;
}
} else {
writeFlowSequence ( state , level , state . dump ) ;
if ( duplicate ) {
state . dump = '&ref_' + duplicateIndex + ' ' + state . dump ;
}
}
} else if ( type === '[object String]' ) {
if ( state . tag !== '?' ) {
writeScalar ( state , state . dump , level , iskey , inblock ) ;
}
} else if ( type === '[object Undefined]' ) {
return false ;
} else {
if ( state . skipInvalid ) return false ;
throw new YAMLException ( 'unacceptable kind of an object to dump ' + type ) ;
}
if ( state . tag !== null && state . tag !== '?' ) {
// Need to encode all characters except those allowed by the spec:
//
// [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */
// [36] ns-hex-digit ::= ns-dec-digit
// | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */
// [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */
// [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-”
// [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#”
// | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,”
// | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]”
//
// Also need to encode '!' because it has special meaning (end of tag prefix).
//
tagStr = encodeURI (
state . tag [ 0 ] === '!' ? state . tag . slice ( 1 ) : state . tag
) . replace ( /!/g , '%21' ) ;
if ( state . tag [ 0 ] === '!' ) {
tagStr = '!' + tagStr ;
} else if ( tagStr . slice ( 0 , 18 ) === 'tag:yaml.org,2002:' ) {
tagStr = '!!' + tagStr . slice ( 18 ) ;
} else {
tagStr = '!<' + tagStr + '>' ;
}
state . dump = tagStr + ' ' + state . dump ;
}
}
return true ;
}
function getDuplicateReferences ( object , state ) {
var objects = [ ] ,
duplicatesIndexes = [ ] ,
index ,
length ;
inspectNode ( object , objects , duplicatesIndexes ) ;
for ( index = 0 , length = duplicatesIndexes . length ; index < length ; index += 1 ) {
state . duplicates . push ( objects [ duplicatesIndexes [ index ] ] ) ;
}
state . usedDuplicates = new Array ( length ) ;
}
function inspectNode ( object , objects , duplicatesIndexes ) {
var objectKeyList ,
index ,
length ;
if ( object !== null && typeof object === 'object' ) {
index = objects . indexOf ( object ) ;
if ( index !== - 1 ) {
if ( duplicatesIndexes . indexOf ( index ) === - 1 ) {
duplicatesIndexes . push ( index ) ;
}
} else {
objects . push ( object ) ;
if ( Array . isArray ( object ) ) {
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
inspectNode ( object [ index ] , objects , duplicatesIndexes ) ;
}
} else {
objectKeyList = Object . keys ( object ) ;
for ( index = 0 , length = objectKeyList . length ; index < length ; index += 1 ) {
inspectNode ( object [ objectKeyList [ index ] ] , objects , duplicatesIndexes ) ;
}
}
}
}
}
function dump ( input , options ) {
options = options || { } ;
var state = new State ( options ) ;
if ( ! state . noRefs ) getDuplicateReferences ( input , state ) ;
var value = input ;
if ( state . replacer ) {
value = state . replacer . call ( { '' : value } , '' , value ) ;
}
if ( writeNode ( state , 0 , value , true , true ) ) return state . dump + '\n' ;
return '' ;
}
module . exports . dump = dump ;
/***/ } ) ,
/***/ 179 :
/***/ ( ( module ) => {
"use strict" ;
// YAML error class. http://stackoverflow.com/questions/8458984
//
function formatError ( exception , compact ) {
var where = '' , message = exception . reason || '(unknown reason)' ;
if ( ! exception . mark ) return message ;
if ( exception . mark . name ) {
where += 'in "' + exception . mark . name + '" ' ;
}
where += '(' + ( exception . mark . line + 1 ) + ':' + ( exception . mark . column + 1 ) + ')' ;
if ( ! compact && exception . mark . snippet ) {
where += '\n\n' + exception . mark . snippet ;
}
return message + ' ' + where ;
}
function YAMLException ( reason , mark ) {
// Super constructor
Error . call ( this ) ;
this . name = 'YAMLException' ;
this . reason = reason ;
this . mark = mark ;
this . message = formatError ( this , false ) ;
// Include stack trace in error object
if ( Error . captureStackTrace ) {
// Chrome and NodeJS
Error . captureStackTrace ( this , this . constructor ) ;
} else {
// FF, IE 10+ and Safari 6+. Fallback for others
this . stack = ( new Error ( ) ) . stack || '' ;
}
}
// Inherit from Error
YAMLException . prototype = Object . create ( Error . prototype ) ;
YAMLException . prototype . constructor = YAMLException ;
YAMLException . prototype . toString = function toString ( compact ) {
return this . name + ': ' + formatError ( this , compact ) ;
} ;
module . exports = YAMLException ;
/***/ } ) ,
/***/ 161 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
/*eslint-disable max-len,no-use-before-define*/
var common = _ _nccwpck _require _ _ ( 829 ) ;
var YAMLException = _ _nccwpck _require _ _ ( 179 ) ;
var makeSnippet = _ _nccwpck _require _ _ ( 975 ) ;
var DEFAULT _SCHEMA = _ _nccwpck _require _ _ ( 759 ) ;
var _hasOwnProperty = Object . prototype . hasOwnProperty ;
var CONTEXT _FLOW _IN = 1 ;
var CONTEXT _FLOW _OUT = 2 ;
var CONTEXT _BLOCK _IN = 3 ;
var CONTEXT _BLOCK _OUT = 4 ;
var CHOMPING _CLIP = 1 ;
var CHOMPING _STRIP = 2 ;
var CHOMPING _KEEP = 3 ;
var PATTERN _NON _PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ ;
var PATTERN _NON _ASCII _LINE _BREAKS = /[\x85\u2028\u2029]/ ;
var PATTERN _FLOW _INDICATORS = /[,\[\]\{\}]/ ;
var PATTERN _TAG _HANDLE = /^(?:!|!!|![a-z\-]+!)$/i ;
var PATTERN _TAG _URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i ;
function _class ( obj ) { return Object . prototype . toString . call ( obj ) ; }
function is _EOL ( c ) {
return ( c === 0x0A /* LF */ ) || ( c === 0x0D /* CR */ ) ;
}
function is _WHITE _SPACE ( c ) {
return ( c === 0x09 /* Tab */ ) || ( c === 0x20 /* Space */ ) ;
}
function is _WS _OR _EOL ( c ) {
return ( c === 0x09 /* Tab */ ) ||
( c === 0x20 /* Space */ ) ||
( c === 0x0A /* LF */ ) ||
( c === 0x0D /* CR */ ) ;
}
function is _FLOW _INDICATOR ( c ) {
return c === 0x2C /* , */ ||
c === 0x5B /* [ */ ||
c === 0x5D /* ] */ ||
c === 0x7B /* { */ ||
c === 0x7D /* } */ ;
}
function fromHexCode ( c ) {
var lc ;
if ( ( 0x30 /* 0 */ <= c ) && ( c <= 0x39 /* 9 */ ) ) {
return c - 0x30 ;
}
/*eslint-disable no-bitwise*/
lc = c | 0x20 ;
if ( ( 0x61 /* a */ <= lc ) && ( lc <= 0x66 /* f */ ) ) {
return lc - 0x61 + 10 ;
}
return - 1 ;
}
function escapedHexLen ( c ) {
if ( c === 0x78 /* x */ ) { return 2 ; }
if ( c === 0x75 /* u */ ) { return 4 ; }
if ( c === 0x55 /* U */ ) { return 8 ; }
return 0 ;
}
function fromDecimalCode ( c ) {
if ( ( 0x30 /* 0 */ <= c ) && ( c <= 0x39 /* 9 */ ) ) {
return c - 0x30 ;
}
return - 1 ;
}
function simpleEscapeSequence ( c ) {
/* eslint-disable indent */
return ( c === 0x30 /* 0 */ ) ? '\x00' :
( c === 0x61 /* a */ ) ? '\x07' :
( c === 0x62 /* b */ ) ? '\x08' :
( c === 0x74 /* t */ ) ? '\x09' :
( c === 0x09 /* Tab */ ) ? '\x09' :
( c === 0x6E /* n */ ) ? '\x0A' :
( c === 0x76 /* v */ ) ? '\x0B' :
( c === 0x66 /* f */ ) ? '\x0C' :
( c === 0x72 /* r */ ) ? '\x0D' :
( c === 0x65 /* e */ ) ? '\x1B' :
( c === 0x20 /* Space */ ) ? ' ' :
( c === 0x22 /* " */ ) ? '\x22' :
( c === 0x2F /* / */ ) ? '/' :
( c === 0x5C /* \ */ ) ? '\x5C' :
( c === 0x4E /* N */ ) ? '\x85' :
( c === 0x5F /* _ */ ) ? '\xA0' :
( c === 0x4C /* L */ ) ? '\u2028' :
( c === 0x50 /* P */ ) ? '\u2029' : '' ;
}
function charFromCodepoint ( c ) {
if ( c <= 0xFFFF ) {
return String . fromCharCode ( c ) ;
}
// Encode UTF-16 surrogate pair
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
return String . fromCharCode (
( ( c - 0x010000 ) >> 10 ) + 0xD800 ,
( ( c - 0x010000 ) & 0x03FF ) + 0xDC00
) ;
}
var simpleEscapeCheck = new Array ( 256 ) ; // integer, for fast access
var simpleEscapeMap = new Array ( 256 ) ;
for ( var i = 0 ; i < 256 ; i ++ ) {
simpleEscapeCheck [ i ] = simpleEscapeSequence ( i ) ? 1 : 0 ;
simpleEscapeMap [ i ] = simpleEscapeSequence ( i ) ;
}
function State ( input , options ) {
this . input = input ;
this . filename = options [ 'filename' ] || null ;
this . schema = options [ 'schema' ] || DEFAULT _SCHEMA ;
this . onWarning = options [ 'onWarning' ] || null ;
// (Hidden) Remove? makes the loader to expect YAML 1.1 documents
// if such documents have no explicit %YAML directive
this . legacy = options [ 'legacy' ] || false ;
this . json = options [ 'json' ] || false ;
this . listener = options [ 'listener' ] || null ;
this . implicitTypes = this . schema . compiledImplicit ;
this . typeMap = this . schema . compiledTypeMap ;
this . length = input . length ;
this . position = 0 ;
this . line = 0 ;
this . lineStart = 0 ;
this . lineIndent = 0 ;
// position of first leading tab in the current line,
// used to make sure there are no tabs in the indentation
this . firstTabInLine = - 1 ;
this . documents = [ ] ;
/ *
this . version ;
this . checkLineBreaks ;
this . tagMap ;
this . anchorMap ;
this . tag ;
this . anchor ;
this . kind ;
this . result ; * /
}
function generateError ( state , message ) {
var mark = {
name : state . filename ,
buffer : state . input . slice ( 0 , - 1 ) , // omit trailing \0
position : state . position ,
line : state . line ,
column : state . position - state . lineStart
} ;
mark . snippet = makeSnippet ( mark ) ;
return new YAMLException ( message , mark ) ;
}
function throwError ( state , message ) {
throw generateError ( state , message ) ;
}
function throwWarning ( state , message ) {
if ( state . onWarning ) {
state . onWarning . call ( null , generateError ( state , message ) ) ;
}
}
var directiveHandlers = {
YAML : function handleYamlDirective ( state , name , args ) {
var match , major , minor ;
if ( state . version !== null ) {
throwError ( state , 'duplication of %YAML directive' ) ;
}
if ( args . length !== 1 ) {
throwError ( state , 'YAML directive accepts exactly one argument' ) ;
}
match = /^([0-9]+)\.([0-9]+)$/ . exec ( args [ 0 ] ) ;
if ( match === null ) {
throwError ( state , 'ill-formed argument of the YAML directive' ) ;
}
major = parseInt ( match [ 1 ] , 10 ) ;
minor = parseInt ( match [ 2 ] , 10 ) ;
if ( major !== 1 ) {
throwError ( state , 'unacceptable YAML version of the document' ) ;
}
state . version = args [ 0 ] ;
state . checkLineBreaks = ( minor < 2 ) ;
if ( minor !== 1 && minor !== 2 ) {
throwWarning ( state , 'unsupported YAML version of the document' ) ;
}
} ,
TAG : function handleTagDirective ( state , name , args ) {
var handle , prefix ;
if ( args . length !== 2 ) {
throwError ( state , 'TAG directive accepts exactly two arguments' ) ;
}
handle = args [ 0 ] ;
prefix = args [ 1 ] ;
if ( ! PATTERN _TAG _HANDLE . test ( handle ) ) {
throwError ( state , 'ill-formed tag handle (first argument) of the TAG directive' ) ;
}
if ( _hasOwnProperty . call ( state . tagMap , handle ) ) {
throwError ( state , 'there is a previously declared suffix for "' + handle + '" tag handle' ) ;
}
if ( ! PATTERN _TAG _URI . test ( prefix ) ) {
throwError ( state , 'ill-formed tag prefix (second argument) of the TAG directive' ) ;
}
try {
prefix = decodeURIComponent ( prefix ) ;
} catch ( err ) {
throwError ( state , 'tag prefix is malformed: ' + prefix ) ;
}
state . tagMap [ handle ] = prefix ;
}
} ;
function captureSegment ( state , start , end , checkJson ) {
var _position , _length , _character , _result ;
if ( start < end ) {
_result = state . input . slice ( start , end ) ;
if ( checkJson ) {
for ( _position = 0 , _length = _result . length ; _position < _length ; _position += 1 ) {
_character = _result . charCodeAt ( _position ) ;
if ( ! ( _character === 0x09 ||
( 0x20 <= _character && _character <= 0x10FFFF ) ) ) {
throwError ( state , 'expected valid JSON character' ) ;
}
}
} else if ( PATTERN _NON _PRINTABLE . test ( _result ) ) {
throwError ( state , 'the stream contains non-printable characters' ) ;
}
state . result += _result ;
}
}
function mergeMappings ( state , destination , source , overridableKeys ) {
var sourceKeys , key , index , quantity ;
if ( ! common . isObject ( source ) ) {
throwError ( state , 'cannot merge mappings; the provided source object is unacceptable' ) ;
}
sourceKeys = Object . keys ( source ) ;
for ( index = 0 , quantity = sourceKeys . length ; index < quantity ; index += 1 ) {
key = sourceKeys [ index ] ;
if ( ! _hasOwnProperty . call ( destination , key ) ) {
destination [ key ] = source [ key ] ;
overridableKeys [ key ] = true ;
}
}
}
function storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , valueNode ,
startLine , startLineStart , startPos ) {
var index , quantity ;
// The output is a plain object here, so keys can only be strings.
// We need to convert keyNode to a string, but doing so can hang the process
// (deeply nested arrays that explode exponentially using aliases).
if ( Array . isArray ( keyNode ) ) {
keyNode = Array . prototype . slice . call ( keyNode ) ;
for ( index = 0 , quantity = keyNode . length ; index < quantity ; index += 1 ) {
if ( Array . isArray ( keyNode [ index ] ) ) {
throwError ( state , 'nested arrays are not supported inside keys' ) ;
}
if ( typeof keyNode === 'object' && _class ( keyNode [ index ] ) === '[object Object]' ) {
keyNode [ index ] = '[object Object]' ;
}
}
}
// Avoid code execution in load() via toString property
// (still use its own toString for arrays, timestamps,
// and whatever user schema extensions happen to have @@toStringTag)
if ( typeof keyNode === 'object' && _class ( keyNode ) === '[object Object]' ) {
keyNode = '[object Object]' ;
}
keyNode = String ( keyNode ) ;
if ( _result === null ) {
_result = { } ;
}
if ( keyTag === 'tag:yaml.org,2002:merge' ) {
if ( Array . isArray ( valueNode ) ) {
for ( index = 0 , quantity = valueNode . length ; index < quantity ; index += 1 ) {
mergeMappings ( state , _result , valueNode [ index ] , overridableKeys ) ;
}
} else {
mergeMappings ( state , _result , valueNode , overridableKeys ) ;
}
} else {
if ( ! state . json &&
! _hasOwnProperty . call ( overridableKeys , keyNode ) &&
_hasOwnProperty . call ( _result , keyNode ) ) {
state . line = startLine || state . line ;
state . lineStart = startLineStart || state . lineStart ;
state . position = startPos || state . position ;
throwError ( state , 'duplicated mapping key' ) ;
}
// used for this specific key only because Object.defineProperty is slow
if ( keyNode === '__proto__' ) {
Object . defineProperty ( _result , keyNode , {
configurable : true ,
enumerable : true ,
writable : true ,
value : valueNode
} ) ;
} else {
_result [ keyNode ] = valueNode ;
}
delete overridableKeys [ keyNode ] ;
}
return _result ;
}
function readLineBreak ( state ) {
var ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch === 0x0A /* LF */ ) {
state . position ++ ;
} else if ( ch === 0x0D /* CR */ ) {
state . position ++ ;
if ( state . input . charCodeAt ( state . position ) === 0x0A /* LF */ ) {
state . position ++ ;
}
} else {
throwError ( state , 'a line break is expected' ) ;
}
state . line += 1 ;
state . lineStart = state . position ;
state . firstTabInLine = - 1 ;
}
function skipSeparationSpace ( state , allowComments , checkIndent ) {
var lineBreaks = 0 ,
ch = state . input . charCodeAt ( state . position ) ;
while ( ch !== 0 ) {
while ( is _WHITE _SPACE ( ch ) ) {
if ( ch === 0x09 /* Tab */ && state . firstTabInLine === - 1 ) {
state . firstTabInLine = state . position ;
}
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( allowComments && ch === 0x23 /* # */ ) {
do {
ch = state . input . charCodeAt ( ++ state . position ) ;
} while ( ch !== 0x0A /* LF */ && ch !== 0x0D /* CR */ && ch !== 0 ) ;
}
if ( is _EOL ( ch ) ) {
readLineBreak ( state ) ;
ch = state . input . charCodeAt ( state . position ) ;
lineBreaks ++ ;
state . lineIndent = 0 ;
while ( ch === 0x20 /* Space */ ) {
state . lineIndent ++ ;
ch = state . input . charCodeAt ( ++ state . position ) ;
}
} else {
break ;
}
}
if ( checkIndent !== - 1 && lineBreaks !== 0 && state . lineIndent < checkIndent ) {
throwWarning ( state , 'deficient indentation' ) ;
}
return lineBreaks ;
}
function testDocumentSeparator ( state ) {
var _position = state . position ,
ch ;
ch = state . input . charCodeAt ( _position ) ;
// Condition state.position === state.lineStart is tested
// in parent on each call, for efficiency. No needs to test here again.
if ( ( ch === 0x2D /* - */ || ch === 0x2E /* . */ ) &&
ch === state . input . charCodeAt ( _position + 1 ) &&
ch === state . input . charCodeAt ( _position + 2 ) ) {
_position += 3 ;
ch = state . input . charCodeAt ( _position ) ;
if ( ch === 0 || is _WS _OR _EOL ( ch ) ) {
return true ;
}
}
return false ;
}
function writeFoldedLines ( state , count ) {
if ( count === 1 ) {
state . result += ' ' ;
} else if ( count > 1 ) {
state . result += common . repeat ( '\n' , count - 1 ) ;
}
}
function readPlainScalar ( state , nodeIndent , withinFlowCollection ) {
var preceding ,
following ,
captureStart ,
captureEnd ,
hasPendingContent ,
_line ,
_lineStart ,
_lineIndent ,
_kind = state . kind ,
_result = state . result ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( is _WS _OR _EOL ( ch ) ||
is _FLOW _INDICATOR ( ch ) ||
ch === 0x23 /* # */ ||
ch === 0x26 /* & */ ||
ch === 0x2A /* * */ ||
ch === 0x21 /* ! */ ||
ch === 0x7C /* | */ ||
ch === 0x3E /* > */ ||
ch === 0x27 /* ' */ ||
ch === 0x22 /* " */ ||
ch === 0x25 /* % */ ||
ch === 0x40 /* @ */ ||
ch === 0x60 /* ` */ ) {
return false ;
}
if ( ch === 0x3F /* ? */ || ch === 0x2D /* - */ ) {
following = state . input . charCodeAt ( state . position + 1 ) ;
if ( is _WS _OR _EOL ( following ) ||
withinFlowCollection && is _FLOW _INDICATOR ( following ) ) {
return false ;
}
}
state . kind = 'scalar' ;
state . result = '' ;
captureStart = captureEnd = state . position ;
hasPendingContent = false ;
while ( ch !== 0 ) {
if ( ch === 0x3A /* : */ ) {
following = state . input . charCodeAt ( state . position + 1 ) ;
if ( is _WS _OR _EOL ( following ) ||
withinFlowCollection && is _FLOW _INDICATOR ( following ) ) {
break ;
}
} else if ( ch === 0x23 /* # */ ) {
preceding = state . input . charCodeAt ( state . position - 1 ) ;
if ( is _WS _OR _EOL ( preceding ) ) {
break ;
}
} else if ( ( state . position === state . lineStart && testDocumentSeparator ( state ) ) ||
withinFlowCollection && is _FLOW _INDICATOR ( ch ) ) {
break ;
} else if ( is _EOL ( ch ) ) {
_line = state . line ;
_lineStart = state . lineStart ;
_lineIndent = state . lineIndent ;
skipSeparationSpace ( state , false , - 1 ) ;
if ( state . lineIndent >= nodeIndent ) {
hasPendingContent = true ;
ch = state . input . charCodeAt ( state . position ) ;
continue ;
} else {
state . position = captureEnd ;
state . line = _line ;
state . lineStart = _lineStart ;
state . lineIndent = _lineIndent ;
break ;
}
}
if ( hasPendingContent ) {
captureSegment ( state , captureStart , captureEnd , false ) ;
writeFoldedLines ( state , state . line - _line ) ;
captureStart = captureEnd = state . position ;
hasPendingContent = false ;
}
if ( ! is _WHITE _SPACE ( ch ) ) {
captureEnd = state . position + 1 ;
}
ch = state . input . charCodeAt ( ++ state . position ) ;
}
captureSegment ( state , captureStart , captureEnd , false ) ;
if ( state . result ) {
return true ;
}
state . kind = _kind ;
state . result = _result ;
return false ;
}
function readSingleQuotedScalar ( state , nodeIndent ) {
var ch ,
captureStart , captureEnd ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch !== 0x27 /* ' */ ) {
return false ;
}
state . kind = 'scalar' ;
state . result = '' ;
state . position ++ ;
captureStart = captureEnd = state . position ;
while ( ( ch = state . input . charCodeAt ( state . position ) ) !== 0 ) {
if ( ch === 0x27 /* ' */ ) {
captureSegment ( state , captureStart , state . position , true ) ;
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( ch === 0x27 /* ' */ ) {
captureStart = state . position ;
state . position ++ ;
captureEnd = state . position ;
} else {
return true ;
}
} else if ( is _EOL ( ch ) ) {
captureSegment ( state , captureStart , captureEnd , true ) ;
writeFoldedLines ( state , skipSeparationSpace ( state , false , nodeIndent ) ) ;
captureStart = captureEnd = state . position ;
} else if ( state . position === state . lineStart && testDocumentSeparator ( state ) ) {
throwError ( state , 'unexpected end of the document within a single quoted scalar' ) ;
} else {
state . position ++ ;
captureEnd = state . position ;
}
}
throwError ( state , 'unexpected end of the stream within a single quoted scalar' ) ;
}
function readDoubleQuotedScalar ( state , nodeIndent ) {
var captureStart ,
captureEnd ,
hexLength ,
hexResult ,
tmp ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch !== 0x22 /* " */ ) {
return false ;
}
state . kind = 'scalar' ;
state . result = '' ;
state . position ++ ;
captureStart = captureEnd = state . position ;
while ( ( ch = state . input . charCodeAt ( state . position ) ) !== 0 ) {
if ( ch === 0x22 /* " */ ) {
captureSegment ( state , captureStart , state . position , true ) ;
state . position ++ ;
return true ;
} else if ( ch === 0x5C /* \ */ ) {
captureSegment ( state , captureStart , state . position , true ) ;
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( is _EOL ( ch ) ) {
skipSeparationSpace ( state , false , nodeIndent ) ;
// TODO: rework to inline fn with no type cast?
} else if ( ch < 256 && simpleEscapeCheck [ ch ] ) {
state . result += simpleEscapeMap [ ch ] ;
state . position ++ ;
} else if ( ( tmp = escapedHexLen ( ch ) ) > 0 ) {
hexLength = tmp ;
hexResult = 0 ;
for ( ; hexLength > 0 ; hexLength -- ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( ( tmp = fromHexCode ( ch ) ) >= 0 ) {
hexResult = ( hexResult << 4 ) + tmp ;
} else {
throwError ( state , 'expected hexadecimal character' ) ;
}
}
state . result += charFromCodepoint ( hexResult ) ;
state . position ++ ;
} else {
throwError ( state , 'unknown escape sequence' ) ;
}
captureStart = captureEnd = state . position ;
} else if ( is _EOL ( ch ) ) {
captureSegment ( state , captureStart , captureEnd , true ) ;
writeFoldedLines ( state , skipSeparationSpace ( state , false , nodeIndent ) ) ;
captureStart = captureEnd = state . position ;
} else if ( state . position === state . lineStart && testDocumentSeparator ( state ) ) {
throwError ( state , 'unexpected end of the document within a double quoted scalar' ) ;
} else {
state . position ++ ;
captureEnd = state . position ;
}
}
throwError ( state , 'unexpected end of the stream within a double quoted scalar' ) ;
}
function readFlowCollection ( state , nodeIndent ) {
var readNext = true ,
_line ,
_lineStart ,
_pos ,
_tag = state . tag ,
_result ,
_anchor = state . anchor ,
following ,
terminator ,
isPair ,
isExplicitPair ,
isMapping ,
overridableKeys = Object . create ( null ) ,
keyNode ,
keyTag ,
valueNode ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch === 0x5B /* [ */ ) {
terminator = 0x5D ; /* ] */
isMapping = false ;
_result = [ ] ;
} else if ( ch === 0x7B /* { */ ) {
terminator = 0x7D ; /* } */
isMapping = true ;
_result = { } ;
} else {
return false ;
}
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = _result ;
}
ch = state . input . charCodeAt ( ++ state . position ) ;
while ( ch !== 0 ) {
skipSeparationSpace ( state , true , nodeIndent ) ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch === terminator ) {
state . position ++ ;
state . tag = _tag ;
state . anchor = _anchor ;
state . kind = isMapping ? 'mapping' : 'sequence' ;
state . result = _result ;
return true ;
} else if ( ! readNext ) {
throwError ( state , 'missed comma between flow collection entries' ) ;
} else if ( ch === 0x2C /* , */ ) {
// "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
throwError ( state , "expected the node content, but found ','" ) ;
}
keyTag = keyNode = valueNode = null ;
isPair = isExplicitPair = false ;
if ( ch === 0x3F /* ? */ ) {
following = state . input . charCodeAt ( state . position + 1 ) ;
if ( is _WS _OR _EOL ( following ) ) {
isPair = isExplicitPair = true ;
state . position ++ ;
skipSeparationSpace ( state , true , nodeIndent ) ;
}
}
_line = state . line ; // Save the current line.
_lineStart = state . lineStart ;
_pos = state . position ;
composeNode ( state , nodeIndent , CONTEXT _FLOW _IN , false , true ) ;
keyTag = state . tag ;
keyNode = state . result ;
skipSeparationSpace ( state , true , nodeIndent ) ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ( isExplicitPair || state . line === _line ) && ch === 0x3A /* : */ ) {
isPair = true ;
ch = state . input . charCodeAt ( ++ state . position ) ;
skipSeparationSpace ( state , true , nodeIndent ) ;
composeNode ( state , nodeIndent , CONTEXT _FLOW _IN , false , true ) ;
valueNode = state . result ;
}
if ( isMapping ) {
storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , valueNode , _line , _lineStart , _pos ) ;
} else if ( isPair ) {
_result . push ( storeMappingPair ( state , null , overridableKeys , keyTag , keyNode , valueNode , _line , _lineStart , _pos ) ) ;
} else {
_result . push ( keyNode ) ;
}
skipSeparationSpace ( state , true , nodeIndent ) ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch === 0x2C /* , */ ) {
readNext = true ;
ch = state . input . charCodeAt ( ++ state . position ) ;
} else {
readNext = false ;
}
}
throwError ( state , 'unexpected end of the stream within a flow collection' ) ;
}
function readBlockScalar ( state , nodeIndent ) {
var captureStart ,
folding ,
chomping = CHOMPING _CLIP ,
didReadContent = false ,
detectedIndent = false ,
textIndent = nodeIndent ,
emptyLines = 0 ,
atMoreIndented = false ,
tmp ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch === 0x7C /* | */ ) {
folding = false ;
} else if ( ch === 0x3E /* > */ ) {
folding = true ;
} else {
return false ;
}
state . kind = 'scalar' ;
state . result = '' ;
while ( ch !== 0 ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( ch === 0x2B /* + */ || ch === 0x2D /* - */ ) {
if ( CHOMPING _CLIP === chomping ) {
chomping = ( ch === 0x2B /* + */ ) ? CHOMPING _KEEP : CHOMPING _STRIP ;
} else {
throwError ( state , 'repeat of a chomping mode identifier' ) ;
}
} else if ( ( tmp = fromDecimalCode ( ch ) ) >= 0 ) {
if ( tmp === 0 ) {
throwError ( state , 'bad explicit indentation width of a block scalar; it cannot be less than one' ) ;
} else if ( ! detectedIndent ) {
textIndent = nodeIndent + tmp - 1 ;
detectedIndent = true ;
} else {
throwError ( state , 'repeat of an indentation width identifier' ) ;
}
} else {
break ;
}
}
if ( is _WHITE _SPACE ( ch ) ) {
do { ch = state . input . charCodeAt ( ++ state . position ) ; }
while ( is _WHITE _SPACE ( ch ) ) ;
if ( ch === 0x23 /* # */ ) {
do { ch = state . input . charCodeAt ( ++ state . position ) ; }
while ( ! is _EOL ( ch ) && ( ch !== 0 ) ) ;
}
}
while ( ch !== 0 ) {
readLineBreak ( state ) ;
state . lineIndent = 0 ;
ch = state . input . charCodeAt ( state . position ) ;
while ( ( ! detectedIndent || state . lineIndent < textIndent ) &&
( ch === 0x20 /* Space */ ) ) {
state . lineIndent ++ ;
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( ! detectedIndent && state . lineIndent > textIndent ) {
textIndent = state . lineIndent ;
}
if ( is _EOL ( ch ) ) {
emptyLines ++ ;
continue ;
}
// End of the scalar.
if ( state . lineIndent < textIndent ) {
// Perform the chomping.
if ( chomping === CHOMPING _KEEP ) {
state . result += common . repeat ( '\n' , didReadContent ? 1 + emptyLines : emptyLines ) ;
} else if ( chomping === CHOMPING _CLIP ) {
if ( didReadContent ) { // i.e. only if the scalar is not empty.
state . result += '\n' ;
}
}
// Break this `while` cycle and go to the funciton's epilogue.
break ;
}
// Folded style: use fancy rules to handle line breaks.
if ( folding ) {
// Lines starting with white space characters (more-indented lines) are not folded.
if ( is _WHITE _SPACE ( ch ) ) {
atMoreIndented = true ;
// except for the first content line (cf. Example 8.1)
state . result += common . repeat ( '\n' , didReadContent ? 1 + emptyLines : emptyLines ) ;
// End of more-indented block.
} else if ( atMoreIndented ) {
atMoreIndented = false ;
state . result += common . repeat ( '\n' , emptyLines + 1 ) ;
// Just one line break - perceive as the same line.
} else if ( emptyLines === 0 ) {
if ( didReadContent ) { // i.e. only if we have already read some scalar content.
state . result += ' ' ;
}
// Several line breaks - perceive as different lines.
} else {
state . result += common . repeat ( '\n' , emptyLines ) ;
}
// Literal style: just add exact number of line breaks between content lines.
} else {
// Keep all line breaks except the header line break.
state . result += common . repeat ( '\n' , didReadContent ? 1 + emptyLines : emptyLines ) ;
}
didReadContent = true ;
detectedIndent = true ;
emptyLines = 0 ;
captureStart = state . position ;
while ( ! is _EOL ( ch ) && ( ch !== 0 ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
captureSegment ( state , captureStart , state . position , false ) ;
}
return true ;
}
function readBlockSequence ( state , nodeIndent ) {
var _line ,
_tag = state . tag ,
_anchor = state . anchor ,
_result = [ ] ,
following ,
detected = false ,
ch ;
// there is a leading tab before this token, so it can't be a block sequence/mapping;
// it can still be flow sequence/mapping or a scalar
if ( state . firstTabInLine !== - 1 ) return false ;
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = _result ;
}
ch = state . input . charCodeAt ( state . position ) ;
while ( ch !== 0 ) {
if ( state . firstTabInLine !== - 1 ) {
state . position = state . firstTabInLine ;
throwError ( state , 'tab characters must not be used in indentation' ) ;
}
if ( ch !== 0x2D /* - */ ) {
break ;
}
following = state . input . charCodeAt ( state . position + 1 ) ;
if ( ! is _WS _OR _EOL ( following ) ) {
break ;
}
detected = true ;
state . position ++ ;
if ( skipSeparationSpace ( state , true , - 1 ) ) {
if ( state . lineIndent <= nodeIndent ) {
_result . push ( null ) ;
ch = state . input . charCodeAt ( state . position ) ;
continue ;
}
}
_line = state . line ;
composeNode ( state , nodeIndent , CONTEXT _BLOCK _IN , false , true ) ;
_result . push ( state . result ) ;
skipSeparationSpace ( state , true , - 1 ) ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ( state . line === _line || state . lineIndent > nodeIndent ) && ( ch !== 0 ) ) {
throwError ( state , 'bad indentation of a sequence entry' ) ;
} else if ( state . lineIndent < nodeIndent ) {
break ;
}
}
if ( detected ) {
state . tag = _tag ;
state . anchor = _anchor ;
state . kind = 'sequence' ;
state . result = _result ;
return true ;
}
return false ;
}
function readBlockMapping ( state , nodeIndent , flowIndent ) {
var following ,
allowCompact ,
_line ,
_keyLine ,
_keyLineStart ,
_keyPos ,
_tag = state . tag ,
_anchor = state . anchor ,
_result = { } ,
overridableKeys = Object . create ( null ) ,
keyTag = null ,
keyNode = null ,
valueNode = null ,
atExplicitKey = false ,
detected = false ,
ch ;
// there is a leading tab before this token, so it can't be a block sequence/mapping;
// it can still be flow sequence/mapping or a scalar
if ( state . firstTabInLine !== - 1 ) return false ;
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = _result ;
}
ch = state . input . charCodeAt ( state . position ) ;
while ( ch !== 0 ) {
if ( ! atExplicitKey && state . firstTabInLine !== - 1 ) {
state . position = state . firstTabInLine ;
throwError ( state , 'tab characters must not be used in indentation' ) ;
}
following = state . input . charCodeAt ( state . position + 1 ) ;
_line = state . line ; // Save the current line.
//
// Explicit notation case. There are two separate blocks:
// first for the key (denoted by "?") and second for the value (denoted by ":")
//
if ( ( ch === 0x3F /* ? */ || ch === 0x3A /* : */ ) && is _WS _OR _EOL ( following ) ) {
if ( ch === 0x3F /* ? */ ) {
if ( atExplicitKey ) {
storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , null , _keyLine , _keyLineStart , _keyPos ) ;
keyTag = keyNode = valueNode = null ;
}
detected = true ;
atExplicitKey = true ;
allowCompact = true ;
} else if ( atExplicitKey ) {
// i.e. 0x3A/* : */ === character after the explicit key.
atExplicitKey = false ;
allowCompact = true ;
} else {
throwError ( state , 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line' ) ;
}
state . position += 1 ;
ch = following ;
//
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
//
} else {
_keyLine = state . line ;
_keyLineStart = state . lineStart ;
_keyPos = state . position ;
if ( ! composeNode ( state , flowIndent , CONTEXT _FLOW _OUT , false , true ) ) {
// Neither implicit nor explicit notation.
// Reading is done. Go to the epilogue.
break ;
}
if ( state . line === _line ) {
ch = state . input . charCodeAt ( state . position ) ;
while ( is _WHITE _SPACE ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( ch === 0x3A /* : */ ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( ! is _WS _OR _EOL ( ch ) ) {
throwError ( state , 'a whitespace character is expected after the key-value separator within a block mapping' ) ;
}
if ( atExplicitKey ) {
storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , null , _keyLine , _keyLineStart , _keyPos ) ;
keyTag = keyNode = valueNode = null ;
}
detected = true ;
atExplicitKey = false ;
allowCompact = false ;
keyTag = state . tag ;
keyNode = state . result ;
} else if ( detected ) {
throwError ( state , 'can not read an implicit mapping pair; a colon is missed' ) ;
} else {
state . tag = _tag ;
state . anchor = _anchor ;
return true ; // Keep the result of `composeNode`.
}
} else if ( detected ) {
throwError ( state , 'can not read a block mapping entry; a multiline key may not be an implicit key' ) ;
} else {
state . tag = _tag ;
state . anchor = _anchor ;
return true ; // Keep the result of `composeNode`.
}
}
//
// Common reading code for both explicit and implicit notations.
//
if ( state . line === _line || state . lineIndent > nodeIndent ) {
if ( atExplicitKey ) {
_keyLine = state . line ;
_keyLineStart = state . lineStart ;
_keyPos = state . position ;
}
if ( composeNode ( state , nodeIndent , CONTEXT _BLOCK _OUT , true , allowCompact ) ) {
if ( atExplicitKey ) {
keyNode = state . result ;
} else {
valueNode = state . result ;
}
}
if ( ! atExplicitKey ) {
storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , valueNode , _keyLine , _keyLineStart , _keyPos ) ;
keyTag = keyNode = valueNode = null ;
}
skipSeparationSpace ( state , true , - 1 ) ;
ch = state . input . charCodeAt ( state . position ) ;
}
if ( ( state . line === _line || state . lineIndent > nodeIndent ) && ( ch !== 0 ) ) {
throwError ( state , 'bad indentation of a mapping entry' ) ;
} else if ( state . lineIndent < nodeIndent ) {
break ;
}
}
//
// Epilogue.
//
// Special case: last mapping's node contains only the key in explicit notation.
if ( atExplicitKey ) {
storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , null , _keyLine , _keyLineStart , _keyPos ) ;
}
// Expose the resulting mapping.
if ( detected ) {
state . tag = _tag ;
state . anchor = _anchor ;
state . kind = 'mapping' ;
state . result = _result ;
}
return detected ;
}
function readTagProperty ( state ) {
var _position ,
isVerbatim = false ,
isNamed = false ,
tagHandle ,
tagName ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch !== 0x21 /* ! */ ) return false ;
if ( state . tag !== null ) {
throwError ( state , 'duplication of a tag property' ) ;
}
ch = state . input . charCodeAt ( ++ state . position ) ;
if ( ch === 0x3C /* < */ ) {
isVerbatim = true ;
ch = state . input . charCodeAt ( ++ state . position ) ;
} else if ( ch === 0x21 /* ! */ ) {
isNamed = true ;
tagHandle = '!!' ;
ch = state . input . charCodeAt ( ++ state . position ) ;
} else {
tagHandle = '!' ;
}
_position = state . position ;
if ( isVerbatim ) {
do { ch = state . input . charCodeAt ( ++ state . position ) ; }
while ( ch !== 0 && ch !== 0x3E /* > */ ) ;
if ( state . position < state . length ) {
tagName = state . input . slice ( _position , state . position ) ;
ch = state . input . charCodeAt ( ++ state . position ) ;
} else {
throwError ( state , 'unexpected end of the stream within a verbatim tag' ) ;
}
} else {
while ( ch !== 0 && ! is _WS _OR _EOL ( ch ) ) {
if ( ch === 0x21 /* ! */ ) {
if ( ! isNamed ) {
tagHandle = state . input . slice ( _position - 1 , state . position + 1 ) ;
if ( ! PATTERN _TAG _HANDLE . test ( tagHandle ) ) {
throwError ( state , 'named tag handle cannot contain such characters' ) ;
}
isNamed = true ;
_position = state . position + 1 ;
} else {
throwError ( state , 'tag suffix cannot contain exclamation marks' ) ;
}
}
ch = state . input . charCodeAt ( ++ state . position ) ;
}
tagName = state . input . slice ( _position , state . position ) ;
if ( PATTERN _FLOW _INDICATORS . test ( tagName ) ) {
throwError ( state , 'tag suffix cannot contain flow indicator characters' ) ;
}
}
if ( tagName && ! PATTERN _TAG _URI . test ( tagName ) ) {
throwError ( state , 'tag name cannot contain such characters: ' + tagName ) ;
}
try {
tagName = decodeURIComponent ( tagName ) ;
} catch ( err ) {
throwError ( state , 'tag name is malformed: ' + tagName ) ;
}
if ( isVerbatim ) {
state . tag = tagName ;
} else if ( _hasOwnProperty . call ( state . tagMap , tagHandle ) ) {
state . tag = state . tagMap [ tagHandle ] + tagName ;
} else if ( tagHandle === '!' ) {
state . tag = '!' + tagName ;
} else if ( tagHandle === '!!' ) {
state . tag = 'tag:yaml.org,2002:' + tagName ;
} else {
throwError ( state , 'undeclared tag handle "' + tagHandle + '"' ) ;
}
return true ;
}
function readAnchorProperty ( state ) {
var _position ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch !== 0x26 /* & */ ) return false ;
if ( state . anchor !== null ) {
throwError ( state , 'duplication of an anchor property' ) ;
}
ch = state . input . charCodeAt ( ++ state . position ) ;
_position = state . position ;
while ( ch !== 0 && ! is _WS _OR _EOL ( ch ) && ! is _FLOW _INDICATOR ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( state . position === _position ) {
throwError ( state , 'name of an anchor node must contain at least one character' ) ;
}
state . anchor = state . input . slice ( _position , state . position ) ;
return true ;
}
function readAlias ( state ) {
var _position , alias ,
ch ;
ch = state . input . charCodeAt ( state . position ) ;
if ( ch !== 0x2A /* * */ ) return false ;
ch = state . input . charCodeAt ( ++ state . position ) ;
_position = state . position ;
while ( ch !== 0 && ! is _WS _OR _EOL ( ch ) && ! is _FLOW _INDICATOR ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( state . position === _position ) {
throwError ( state , 'name of an alias node must contain at least one character' ) ;
}
alias = state . input . slice ( _position , state . position ) ;
if ( ! _hasOwnProperty . call ( state . anchorMap , alias ) ) {
throwError ( state , 'unidentified alias "' + alias + '"' ) ;
}
state . result = state . anchorMap [ alias ] ;
skipSeparationSpace ( state , true , - 1 ) ;
return true ;
}
function composeNode ( state , parentIndent , nodeContext , allowToSeek , allowCompact ) {
var allowBlockStyles ,
allowBlockScalars ,
allowBlockCollections ,
indentStatus = 1 , // 1: this>parent, 0: this=parent, -1: this<parent
atNewLine = false ,
hasContent = false ,
typeIndex ,
typeQuantity ,
typeList ,
type ,
flowIndent ,
blockIndent ;
if ( state . listener !== null ) {
state . listener ( 'open' , state ) ;
}
state . tag = null ;
state . anchor = null ;
state . kind = null ;
state . result = null ;
allowBlockStyles = allowBlockScalars = allowBlockCollections =
CONTEXT _BLOCK _OUT === nodeContext ||
CONTEXT _BLOCK _IN === nodeContext ;
if ( allowToSeek ) {
if ( skipSeparationSpace ( state , true , - 1 ) ) {
atNewLine = true ;
if ( state . lineIndent > parentIndent ) {
indentStatus = 1 ;
} else if ( state . lineIndent === parentIndent ) {
indentStatus = 0 ;
} else if ( state . lineIndent < parentIndent ) {
indentStatus = - 1 ;
}
}
}
if ( indentStatus === 1 ) {
while ( readTagProperty ( state ) || readAnchorProperty ( state ) ) {
if ( skipSeparationSpace ( state , true , - 1 ) ) {
atNewLine = true ;
allowBlockCollections = allowBlockStyles ;
if ( state . lineIndent > parentIndent ) {
indentStatus = 1 ;
} else if ( state . lineIndent === parentIndent ) {
indentStatus = 0 ;
} else if ( state . lineIndent < parentIndent ) {
indentStatus = - 1 ;
}
} else {
allowBlockCollections = false ;
}
}
}
if ( allowBlockCollections ) {
allowBlockCollections = atNewLine || allowCompact ;
}
if ( indentStatus === 1 || CONTEXT _BLOCK _OUT === nodeContext ) {
if ( CONTEXT _FLOW _IN === nodeContext || CONTEXT _FLOW _OUT === nodeContext ) {
flowIndent = parentIndent ;
} else {
flowIndent = parentIndent + 1 ;
}
blockIndent = state . position - state . lineStart ;
if ( indentStatus === 1 ) {
if ( allowBlockCollections &&
( readBlockSequence ( state , blockIndent ) ||
readBlockMapping ( state , blockIndent , flowIndent ) ) ||
readFlowCollection ( state , flowIndent ) ) {
hasContent = true ;
} else {
if ( ( allowBlockScalars && readBlockScalar ( state , flowIndent ) ) ||
readSingleQuotedScalar ( state , flowIndent ) ||
readDoubleQuotedScalar ( state , flowIndent ) ) {
hasContent = true ;
} else if ( readAlias ( state ) ) {
hasContent = true ;
if ( state . tag !== null || state . anchor !== null ) {
throwError ( state , 'alias node should not have any properties' ) ;
}
} else if ( readPlainScalar ( state , flowIndent , CONTEXT _FLOW _IN === nodeContext ) ) {
hasContent = true ;
if ( state . tag === null ) {
state . tag = '?' ;
}
}
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = state . result ;
}
}
} else if ( indentStatus === 0 ) {
// Special case: block sequences are allowed to have same indentation level as the parent.
// http://www.yaml.org/spec/1.2/spec.html#id2799784
hasContent = allowBlockCollections && readBlockSequence ( state , blockIndent ) ;
}
}
if ( state . tag === null ) {
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = state . result ;
}
} else if ( state . tag === '?' ) {
// Implicit resolving is not allowed for non-scalar types, and '?'
// non-specific tag is only automatically assigned to plain scalars.
//
// We only need to check kind conformity in case user explicitly assigns '?'
// tag, for example like this: "!<?> [0]"
//
if ( state . result !== null && state . kind !== 'scalar' ) {
throwError ( state , 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state . kind + '"' ) ;
}
for ( typeIndex = 0 , typeQuantity = state . implicitTypes . length ; typeIndex < typeQuantity ; typeIndex += 1 ) {
type = state . implicitTypes [ typeIndex ] ;
if ( type . resolve ( state . result ) ) { // `state.result` updated in resolver if matched
state . result = type . construct ( state . result ) ;
state . tag = type . tag ;
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = state . result ;
}
break ;
}
}
} else if ( state . tag !== '!' ) {
if ( _hasOwnProperty . call ( state . typeMap [ state . kind || 'fallback' ] , state . tag ) ) {
type = state . typeMap [ state . kind || 'fallback' ] [ state . tag ] ;
} else {
// looking for multi type
type = null ;
typeList = state . typeMap . multi [ state . kind || 'fallback' ] ;
for ( typeIndex = 0 , typeQuantity = typeList . length ; typeIndex < typeQuantity ; typeIndex += 1 ) {
if ( state . tag . slice ( 0 , typeList [ typeIndex ] . tag . length ) === typeList [ typeIndex ] . tag ) {
type = typeList [ typeIndex ] ;
break ;
}
}
}
if ( ! type ) {
throwError ( state , 'unknown tag !<' + state . tag + '>' ) ;
}
if ( state . result !== null && type . kind !== state . kind ) {
throwError ( state , 'unacceptable node kind for !<' + state . tag + '> tag; it should be "' + type . kind + '", not "' + state . kind + '"' ) ;
}
if ( ! type . resolve ( state . result , state . tag ) ) { // `state.result` updated in resolver if matched
throwError ( state , 'cannot resolve a node with !<' + state . tag + '> explicit tag' ) ;
} else {
state . result = type . construct ( state . result , state . tag ) ;
if ( state . anchor !== null ) {
state . anchorMap [ state . anchor ] = state . result ;
}
}
}
if ( state . listener !== null ) {
state . listener ( 'close' , state ) ;
}
return state . tag !== null || state . anchor !== null || hasContent ;
}
function readDocument ( state ) {
var documentStart = state . position ,
_position ,
directiveName ,
directiveArgs ,
hasDirectives = false ,
ch ;
state . version = null ;
state . checkLineBreaks = state . legacy ;
state . tagMap = Object . create ( null ) ;
state . anchorMap = Object . create ( null ) ;
while ( ( ch = state . input . charCodeAt ( state . position ) ) !== 0 ) {
skipSeparationSpace ( state , true , - 1 ) ;
ch = state . input . charCodeAt ( state . position ) ;
if ( state . lineIndent > 0 || ch !== 0x25 /* % */ ) {
break ;
}
hasDirectives = true ;
ch = state . input . charCodeAt ( ++ state . position ) ;
_position = state . position ;
while ( ch !== 0 && ! is _WS _OR _EOL ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
directiveName = state . input . slice ( _position , state . position ) ;
directiveArgs = [ ] ;
if ( directiveName . length < 1 ) {
throwError ( state , 'directive name must not be less than one character in length' ) ;
}
while ( ch !== 0 ) {
while ( is _WHITE _SPACE ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
if ( ch === 0x23 /* # */ ) {
do { ch = state . input . charCodeAt ( ++ state . position ) ; }
while ( ch !== 0 && ! is _EOL ( ch ) ) ;
break ;
}
if ( is _EOL ( ch ) ) break ;
_position = state . position ;
while ( ch !== 0 && ! is _WS _OR _EOL ( ch ) ) {
ch = state . input . charCodeAt ( ++ state . position ) ;
}
directiveArgs . push ( state . input . slice ( _position , state . position ) ) ;
}
if ( ch !== 0 ) readLineBreak ( state ) ;
if ( _hasOwnProperty . call ( directiveHandlers , directiveName ) ) {
directiveHandlers [ directiveName ] ( state , directiveName , directiveArgs ) ;
} else {
throwWarning ( state , 'unknown document directive "' + directiveName + '"' ) ;
}
}
skipSeparationSpace ( state , true , - 1 ) ;
if ( state . lineIndent === 0 &&
state . input . charCodeAt ( state . position ) === 0x2D /* - */ &&
state . input . charCodeAt ( state . position + 1 ) === 0x2D /* - */ &&
state . input . charCodeAt ( state . position + 2 ) === 0x2D /* - */ ) {
state . position += 3 ;
skipSeparationSpace ( state , true , - 1 ) ;
} else if ( hasDirectives ) {
throwError ( state , 'directives end mark is expected' ) ;
}
composeNode ( state , state . lineIndent - 1 , CONTEXT _BLOCK _OUT , false , true ) ;
skipSeparationSpace ( state , true , - 1 ) ;
if ( state . checkLineBreaks &&
PATTERN _NON _ASCII _LINE _BREAKS . test ( state . input . slice ( documentStart , state . position ) ) ) {
throwWarning ( state , 'non-ASCII line breaks are interpreted as content' ) ;
}
state . documents . push ( state . result ) ;
if ( state . position === state . lineStart && testDocumentSeparator ( state ) ) {
if ( state . input . charCodeAt ( state . position ) === 0x2E /* . */ ) {
state . position += 3 ;
skipSeparationSpace ( state , true , - 1 ) ;
}
return ;
}
if ( state . position < ( state . length - 1 ) ) {
throwError ( state , 'end of the stream or a document separator is expected' ) ;
} else {
return ;
}
}
function loadDocuments ( input , options ) {
input = String ( input ) ;
options = options || { } ;
if ( input . length !== 0 ) {
// Add tailing `\n` if not exists
if ( input . charCodeAt ( input . length - 1 ) !== 0x0A /* LF */ &&
input . charCodeAt ( input . length - 1 ) !== 0x0D /* CR */ ) {
input += '\n' ;
}
// Strip BOM
if ( input . charCodeAt ( 0 ) === 0xFEFF ) {
input = input . slice ( 1 ) ;
}
}
var state = new State ( input , options ) ;
var nullpos = input . indexOf ( '\0' ) ;
if ( nullpos !== - 1 ) {
state . position = nullpos ;
throwError ( state , 'null byte is not allowed in input' ) ;
}
// Use 0 as string terminator. That significantly simplifies bounds check.
state . input += '\0' ;
while ( state . input . charCodeAt ( state . position ) === 0x20 /* Space */ ) {
state . lineIndent += 1 ;
state . position += 1 ;
}
while ( state . position < ( state . length - 1 ) ) {
readDocument ( state ) ;
}
return state . documents ;
}
function loadAll ( input , iterator , options ) {
if ( iterator !== null && typeof iterator === 'object' && typeof options === 'undefined' ) {
options = iterator ;
iterator = null ;
}
var documents = loadDocuments ( input , options ) ;
if ( typeof iterator !== 'function' ) {
return documents ;
}
for ( var index = 0 , length = documents . length ; index < length ; index += 1 ) {
iterator ( documents [ index ] ) ;
}
}
function load ( input , options ) {
var documents = loadDocuments ( input , options ) ;
if ( documents . length === 0 ) {
/*eslint-disable no-undefined*/
return undefined ;
} else if ( documents . length === 1 ) {
return documents [ 0 ] ;
}
throw new YAMLException ( 'expected a single document in the stream, but found more' ) ;
}
module . exports . loadAll = loadAll ;
module . exports . load = load ;
/***/ } ) ,
/***/ 82 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
/*eslint-disable max-len*/
var YAMLException = _ _nccwpck _require _ _ ( 179 ) ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
function compileList ( schema , name ) {
var result = [ ] ;
schema [ name ] . forEach ( function ( currentType ) {
var newIndex = result . length ;
result . forEach ( function ( previousType , previousIndex ) {
if ( previousType . tag === currentType . tag &&
previousType . kind === currentType . kind &&
previousType . multi === currentType . multi ) {
newIndex = previousIndex ;
}
} ) ;
result [ newIndex ] = currentType ;
} ) ;
return result ;
}
function compileMap ( /* lists... */ ) {
var result = {
scalar : { } ,
sequence : { } ,
mapping : { } ,
fallback : { } ,
multi : {
scalar : [ ] ,
sequence : [ ] ,
mapping : [ ] ,
fallback : [ ]
}
} , index , length ;
function collectType ( type ) {
if ( type . multi ) {
result . multi [ type . kind ] . push ( type ) ;
result . multi [ 'fallback' ] . push ( type ) ;
} else {
result [ type . kind ] [ type . tag ] = result [ 'fallback' ] [ type . tag ] = type ;
}
}
for ( index = 0 , length = arguments . length ; index < length ; index += 1 ) {
arguments [ index ] . forEach ( collectType ) ;
}
return result ;
}
function Schema ( definition ) {
return this . extend ( definition ) ;
}
Schema . prototype . extend = function extend ( definition ) {
var implicit = [ ] ;
var explicit = [ ] ;
if ( definition instanceof Type ) {
// Schema.extend(type)
explicit . push ( definition ) ;
} else if ( Array . isArray ( definition ) ) {
// Schema.extend([ type1, type2, ... ])
explicit = explicit . concat ( definition ) ;
} else if ( definition && ( Array . isArray ( definition . implicit ) || Array . isArray ( definition . explicit ) ) ) {
// Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] })
if ( definition . implicit ) implicit = implicit . concat ( definition . implicit ) ;
if ( definition . explicit ) explicit = explicit . concat ( definition . explicit ) ;
} else {
throw new YAMLException ( 'Schema.extend argument should be a Type, [ Type ], ' +
'or a schema definition ({ implicit: [...], explicit: [...] })' ) ;
}
implicit . forEach ( function ( type ) {
if ( ! ( type instanceof Type ) ) {
throw new YAMLException ( 'Specified list of YAML types (or a single Type object) contains a non-Type object.' ) ;
}
if ( type . loadKind && type . loadKind !== 'scalar' ) {
throw new YAMLException ( 'There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.' ) ;
}
if ( type . multi ) {
throw new YAMLException ( 'There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.' ) ;
}
} ) ;
explicit . forEach ( function ( type ) {
if ( ! ( type instanceof Type ) ) {
throw new YAMLException ( 'Specified list of YAML types (or a single Type object) contains a non-Type object.' ) ;
}
} ) ;
var result = Object . create ( Schema . prototype ) ;
result . implicit = ( this . implicit || [ ] ) . concat ( implicit ) ;
result . explicit = ( this . explicit || [ ] ) . concat ( explicit ) ;
result . compiledImplicit = compileList ( result , 'implicit' ) ;
result . compiledExplicit = compileList ( result , 'explicit' ) ;
result . compiledTypeMap = compileMap ( result . compiledImplicit , result . compiledExplicit ) ;
return result ;
} ;
module . exports = Schema ;
/***/ } ) ,
/***/ 11 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
// Standard YAML's Core schema.
// http://www.yaml.org/spec/1.2/spec.html#id2804923
//
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
// So, Core schema has no distinctions from JSON schema is JS-YAML.
module . exports = _ _nccwpck _require _ _ ( 35 ) ;
/***/ } ) ,
/***/ 759 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
// JS-YAML's default schema for `safeLoad` function.
// It is not described in the YAML specification.
//
// This schema is based on standard YAML's Core schema and includes most of
// extra types described at YAML tag repository. (http://yaml.org/type/)
2021-12-24 17:13:55 -05:00
module . exports = ( _ _nccwpck _require _ _ ( 11 ) . extend ) ( {
2021-10-01 03:17:49 -04:00
implicit : [
_ _nccwpck _require _ _ ( 212 ) ,
_ _nccwpck _require _ _ ( 104 )
] ,
explicit : [
_ _nccwpck _require _ _ ( 900 ) ,
_ _nccwpck _require _ _ ( 46 ) ,
_ _nccwpck _require _ _ ( 860 ) ,
_ _nccwpck _require _ _ ( 548 )
]
} ) ;
/***/ } ) ,
/***/ 562 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
// Standard YAML's Failsafe schema.
// http://www.yaml.org/spec/1.2/spec.html#id2802346
var Schema = _ _nccwpck _require _ _ ( 82 ) ;
module . exports = new Schema ( {
explicit : [
_ _nccwpck _require _ _ ( 619 ) ,
2021-12-24 17:13:55 -05:00
_ _nccwpck _require _ _ ( 546 ) ,
2021-10-01 03:17:49 -04:00
_ _nccwpck _require _ _ ( 150 )
]
} ) ;
/***/ } ) ,
/***/ 35 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
// Standard YAML's JSON schema.
// http://www.yaml.org/spec/1.2/spec.html#id2803231
//
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
// So, this schema is not such strict as defined in the YAML specification.
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2021-12-24 17:13:55 -05:00
module . exports = ( _ _nccwpck _require _ _ ( 562 ) . extend ) ( {
2021-10-01 03:17:49 -04:00
implicit : [
_ _nccwpck _require _ _ ( 721 ) ,
_ _nccwpck _require _ _ ( 993 ) ,
_ _nccwpck _require _ _ ( 615 ) ,
_ _nccwpck _require _ _ ( 705 )
]
} ) ;
/***/ } ) ,
/***/ 975 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var common = _ _nccwpck _require _ _ ( 829 ) ;
// get snippet for a single line, respecting maxLength
function getLine ( buffer , lineStart , lineEnd , position , maxLineLength ) {
var head = '' ;
var tail = '' ;
var maxHalfLength = Math . floor ( maxLineLength / 2 ) - 1 ;
if ( position - lineStart > maxHalfLength ) {
head = ' ... ' ;
lineStart = position - maxHalfLength + head . length ;
}
if ( lineEnd - position > maxHalfLength ) {
tail = ' ...' ;
lineEnd = position + maxHalfLength - tail . length ;
}
return {
str : head + buffer . slice ( lineStart , lineEnd ) . replace ( /\t/g , '→' ) + tail ,
pos : position - lineStart + head . length // relative position
} ;
}
function padStart ( string , max ) {
return common . repeat ( ' ' , max - string . length ) + string ;
}
function makeSnippet ( mark , options ) {
options = Object . create ( options || null ) ;
if ( ! mark . buffer ) return null ;
if ( ! options . maxLength ) options . maxLength = 79 ;
if ( typeof options . indent !== 'number' ) options . indent = 1 ;
if ( typeof options . linesBefore !== 'number' ) options . linesBefore = 3 ;
if ( typeof options . linesAfter !== 'number' ) options . linesAfter = 2 ;
var re = /\r?\n|\r|\0/g ;
var lineStarts = [ 0 ] ;
var lineEnds = [ ] ;
var match ;
var foundLineNo = - 1 ;
while ( ( match = re . exec ( mark . buffer ) ) ) {
lineEnds . push ( match . index ) ;
lineStarts . push ( match . index + match [ 0 ] . length ) ;
if ( mark . position <= match . index && foundLineNo < 0 ) {
foundLineNo = lineStarts . length - 2 ;
}
}
if ( foundLineNo < 0 ) foundLineNo = lineStarts . length - 1 ;
var result = '' , i , line ;
var lineNoLength = Math . min ( mark . line + options . linesAfter , lineEnds . length ) . toString ( ) . length ;
var maxLineLength = options . maxLength - ( options . indent + lineNoLength + 3 ) ;
for ( i = 1 ; i <= options . linesBefore ; i ++ ) {
if ( foundLineNo - i < 0 ) break ;
line = getLine (
mark . buffer ,
lineStarts [ foundLineNo - i ] ,
lineEnds [ foundLineNo - i ] ,
mark . position - ( lineStarts [ foundLineNo ] - lineStarts [ foundLineNo - i ] ) ,
maxLineLength
) ;
result = common . repeat ( ' ' , options . indent ) + padStart ( ( mark . line - i + 1 ) . toString ( ) , lineNoLength ) +
' | ' + line . str + '\n' + result ;
}
line = getLine ( mark . buffer , lineStarts [ foundLineNo ] , lineEnds [ foundLineNo ] , mark . position , maxLineLength ) ;
result += common . repeat ( ' ' , options . indent ) + padStart ( ( mark . line + 1 ) . toString ( ) , lineNoLength ) +
' | ' + line . str + '\n' ;
result += common . repeat ( '-' , options . indent + lineNoLength + 3 + line . pos ) + '^' + '\n' ;
for ( i = 1 ; i <= options . linesAfter ; i ++ ) {
if ( foundLineNo + i >= lineEnds . length ) break ;
line = getLine (
mark . buffer ,
lineStarts [ foundLineNo + i ] ,
lineEnds [ foundLineNo + i ] ,
mark . position - ( lineStarts [ foundLineNo ] - lineStarts [ foundLineNo + i ] ) ,
maxLineLength
) ;
result += common . repeat ( ' ' , options . indent ) + padStart ( ( mark . line + i + 1 ) . toString ( ) , lineNoLength ) +
' | ' + line . str + '\n' ;
}
return result . replace ( /\n$/ , '' ) ;
}
module . exports = makeSnippet ;
/***/ } ) ,
/***/ 73 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var YAMLException = _ _nccwpck _require _ _ ( 179 ) ;
var TYPE _CONSTRUCTOR _OPTIONS = [
'kind' ,
'multi' ,
'resolve' ,
'construct' ,
'instanceOf' ,
'predicate' ,
'represent' ,
'representName' ,
'defaultStyle' ,
'styleAliases'
] ;
var YAML _NODE _KINDS = [
'scalar' ,
'sequence' ,
'mapping'
] ;
function compileStyleAliases ( map ) {
var result = { } ;
if ( map !== null ) {
Object . keys ( map ) . forEach ( function ( style ) {
map [ style ] . forEach ( function ( alias ) {
result [ String ( alias ) ] = style ;
} ) ;
} ) ;
}
return result ;
}
function Type ( tag , options ) {
options = options || { } ;
Object . keys ( options ) . forEach ( function ( name ) {
if ( TYPE _CONSTRUCTOR _OPTIONS . indexOf ( name ) === - 1 ) {
throw new YAMLException ( 'Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.' ) ;
}
} ) ;
// TODO: Add tag format check.
this . options = options ; // keep original options in case user wants to extend this type later
this . tag = tag ;
this . kind = options [ 'kind' ] || null ;
this . resolve = options [ 'resolve' ] || function ( ) { return true ; } ;
this . construct = options [ 'construct' ] || function ( data ) { return data ; } ;
this . instanceOf = options [ 'instanceOf' ] || null ;
this . predicate = options [ 'predicate' ] || null ;
this . represent = options [ 'represent' ] || null ;
this . representName = options [ 'representName' ] || null ;
this . defaultStyle = options [ 'defaultStyle' ] || null ;
this . multi = options [ 'multi' ] || false ;
this . styleAliases = compileStyleAliases ( options [ 'styleAliases' ] || null ) ;
if ( YAML _NODE _KINDS . indexOf ( this . kind ) === - 1 ) {
throw new YAMLException ( 'Unknown kind "' + this . kind + '" is specified for "' + tag + '" YAML type.' ) ;
}
}
module . exports = Type ;
/***/ } ) ,
/***/ 900 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
/*eslint-disable no-bitwise*/
var Type = _ _nccwpck _require _ _ ( 73 ) ;
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
var BASE64 _MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r' ;
function resolveYamlBinary ( data ) {
if ( data === null ) return false ;
var code , idx , bitlen = 0 , max = data . length , map = BASE64 _MAP ;
// Convert one by one.
for ( idx = 0 ; idx < max ; idx ++ ) {
code = map . indexOf ( data . charAt ( idx ) ) ;
// Skip CR/LF
if ( code > 64 ) continue ;
// Fail on illegal characters
if ( code < 0 ) return false ;
bitlen += 6 ;
}
// If there are any bits left, source was corrupted
return ( bitlen % 8 ) === 0 ;
}
function constructYamlBinary ( data ) {
var idx , tailbits ,
input = data . replace ( /[\r\n=]/g , '' ) , // remove CR/LF & padding to simplify scan
max = input . length ,
map = BASE64 _MAP ,
bits = 0 ,
result = [ ] ;
// Collect by 6*4 bits (3 bytes)
for ( idx = 0 ; idx < max ; idx ++ ) {
if ( ( idx % 4 === 0 ) && idx ) {
result . push ( ( bits >> 16 ) & 0xFF ) ;
result . push ( ( bits >> 8 ) & 0xFF ) ;
result . push ( bits & 0xFF ) ;
}
bits = ( bits << 6 ) | map . indexOf ( input . charAt ( idx ) ) ;
}
// Dump tail
tailbits = ( max % 4 ) * 6 ;
if ( tailbits === 0 ) {
result . push ( ( bits >> 16 ) & 0xFF ) ;
result . push ( ( bits >> 8 ) & 0xFF ) ;
result . push ( bits & 0xFF ) ;
} else if ( tailbits === 18 ) {
result . push ( ( bits >> 10 ) & 0xFF ) ;
result . push ( ( bits >> 2 ) & 0xFF ) ;
} else if ( tailbits === 12 ) {
result . push ( ( bits >> 4 ) & 0xFF ) ;
}
return new Uint8Array ( result ) ;
}
function representYamlBinary ( object /*, style*/ ) {
var result = '' , bits = 0 , idx , tail ,
max = object . length ,
map = BASE64 _MAP ;
// Convert every three bytes to 4 ASCII characters.
for ( idx = 0 ; idx < max ; idx ++ ) {
if ( ( idx % 3 === 0 ) && idx ) {
result += map [ ( bits >> 18 ) & 0x3F ] ;
result += map [ ( bits >> 12 ) & 0x3F ] ;
result += map [ ( bits >> 6 ) & 0x3F ] ;
result += map [ bits & 0x3F ] ;
}
bits = ( bits << 8 ) + object [ idx ] ;
}
// Dump tail
tail = max % 3 ;
if ( tail === 0 ) {
result += map [ ( bits >> 18 ) & 0x3F ] ;
result += map [ ( bits >> 12 ) & 0x3F ] ;
result += map [ ( bits >> 6 ) & 0x3F ] ;
result += map [ bits & 0x3F ] ;
} else if ( tail === 2 ) {
result += map [ ( bits >> 10 ) & 0x3F ] ;
result += map [ ( bits >> 4 ) & 0x3F ] ;
result += map [ ( bits << 2 ) & 0x3F ] ;
result += map [ 64 ] ;
} else if ( tail === 1 ) {
result += map [ ( bits >> 2 ) & 0x3F ] ;
result += map [ ( bits << 4 ) & 0x3F ] ;
result += map [ 64 ] ;
result += map [ 64 ] ;
}
return result ;
}
function isBinary ( obj ) {
return Object . prototype . toString . call ( obj ) === '[object Uint8Array]' ;
}
module . exports = new Type ( 'tag:yaml.org,2002:binary' , {
kind : 'scalar' ,
resolve : resolveYamlBinary ,
construct : constructYamlBinary ,
predicate : isBinary ,
represent : representYamlBinary
} ) ;
/***/ } ) ,
/***/ 993 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
function resolveYamlBoolean ( data ) {
if ( data === null ) return false ;
var max = data . length ;
return ( max === 4 && ( data === 'true' || data === 'True' || data === 'TRUE' ) ) ||
( max === 5 && ( data === 'false' || data === 'False' || data === 'FALSE' ) ) ;
}
function constructYamlBoolean ( data ) {
return data === 'true' ||
data === 'True' ||
data === 'TRUE' ;
}
function isBoolean ( object ) {
return Object . prototype . toString . call ( object ) === '[object Boolean]' ;
}
module . exports = new Type ( 'tag:yaml.org,2002:bool' , {
kind : 'scalar' ,
resolve : resolveYamlBoolean ,
construct : constructYamlBoolean ,
predicate : isBoolean ,
represent : {
lowercase : function ( object ) { return object ? 'true' : 'false' ; } ,
uppercase : function ( object ) { return object ? 'TRUE' : 'FALSE' ; } ,
camelcase : function ( object ) { return object ? 'True' : 'False' ; }
} ,
defaultStyle : 'lowercase'
} ) ;
/***/ } ) ,
/***/ 705 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var common = _ _nccwpck _require _ _ ( 829 ) ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
var YAML _FLOAT _PATTERN = new RegExp (
// 2.5e4, 2.5 and integers
'^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
// .2e4, .2
// special case, seems not from spec
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
// .inf
'|[-+]?\\.(?:inf|Inf|INF)' +
// .nan
'|\\.(?:nan|NaN|NAN))$' ) ;
function resolveYamlFloat ( data ) {
if ( data === null ) return false ;
if ( ! YAML _FLOAT _PATTERN . test ( data ) ||
// Quick hack to not allow integers end with `_`
// Probably should update regexp & check speed
data [ data . length - 1 ] === '_' ) {
return false ;
}
return true ;
}
function constructYamlFloat ( data ) {
var value , sign ;
value = data . replace ( /_/g , '' ) . toLowerCase ( ) ;
sign = value [ 0 ] === '-' ? - 1 : 1 ;
if ( '+-' . indexOf ( value [ 0 ] ) >= 0 ) {
value = value . slice ( 1 ) ;
}
if ( value === '.inf' ) {
return ( sign === 1 ) ? Number . POSITIVE _INFINITY : Number . NEGATIVE _INFINITY ;
} else if ( value === '.nan' ) {
return NaN ;
}
return sign * parseFloat ( value , 10 ) ;
}
var SCIENTIFIC _WITHOUT _DOT = /^[-+]?[0-9]+e/ ;
function representYamlFloat ( object , style ) {
var res ;
if ( isNaN ( object ) ) {
switch ( style ) {
case 'lowercase' : return '.nan' ;
case 'uppercase' : return '.NAN' ;
case 'camelcase' : return '.NaN' ;
}
} else if ( Number . POSITIVE _INFINITY === object ) {
switch ( style ) {
case 'lowercase' : return '.inf' ;
case 'uppercase' : return '.INF' ;
case 'camelcase' : return '.Inf' ;
}
} else if ( Number . NEGATIVE _INFINITY === object ) {
switch ( style ) {
case 'lowercase' : return '-.inf' ;
case 'uppercase' : return '-.INF' ;
case 'camelcase' : return '-.Inf' ;
}
} else if ( common . isNegativeZero ( object ) ) {
return '-0.0' ;
}
res = object . toString ( 10 ) ;
// JS stringifier can build scientific format without dots: 5e-100,
// while YAML requres dot: 5.e-100. Fix it with simple hack
return SCIENTIFIC _WITHOUT _DOT . test ( res ) ? res . replace ( 'e' , '.e' ) : res ;
}
function isFloat ( object ) {
return ( Object . prototype . toString . call ( object ) === '[object Number]' ) &&
( object % 1 !== 0 || common . isNegativeZero ( object ) ) ;
}
module . exports = new Type ( 'tag:yaml.org,2002:float' , {
kind : 'scalar' ,
resolve : resolveYamlFloat ,
construct : constructYamlFloat ,
predicate : isFloat ,
represent : representYamlFloat ,
defaultStyle : 'lowercase'
} ) ;
/***/ } ) ,
/***/ 615 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var common = _ _nccwpck _require _ _ ( 829 ) ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
function isHexCode ( c ) {
return ( ( 0x30 /* 0 */ <= c ) && ( c <= 0x39 /* 9 */ ) ) ||
( ( 0x41 /* A */ <= c ) && ( c <= 0x46 /* F */ ) ) ||
( ( 0x61 /* a */ <= c ) && ( c <= 0x66 /* f */ ) ) ;
}
function isOctCode ( c ) {
return ( ( 0x30 /* 0 */ <= c ) && ( c <= 0x37 /* 7 */ ) ) ;
}
function isDecCode ( c ) {
return ( ( 0x30 /* 0 */ <= c ) && ( c <= 0x39 /* 9 */ ) ) ;
}
function resolveYamlInteger ( data ) {
if ( data === null ) return false ;
var max = data . length ,
index = 0 ,
hasDigits = false ,
ch ;
if ( ! max ) return false ;
ch = data [ index ] ;
// sign
if ( ch === '-' || ch === '+' ) {
ch = data [ ++ index ] ;
}
if ( ch === '0' ) {
// 0
if ( index + 1 === max ) return true ;
ch = data [ ++ index ] ;
// base 2, base 8, base 16
if ( ch === 'b' ) {
// base 2
index ++ ;
for ( ; index < max ; index ++ ) {
ch = data [ index ] ;
if ( ch === '_' ) continue ;
if ( ch !== '0' && ch !== '1' ) return false ;
hasDigits = true ;
}
return hasDigits && ch !== '_' ;
}
if ( ch === 'x' ) {
// base 16
index ++ ;
for ( ; index < max ; index ++ ) {
ch = data [ index ] ;
if ( ch === '_' ) continue ;
if ( ! isHexCode ( data . charCodeAt ( index ) ) ) return false ;
hasDigits = true ;
}
return hasDigits && ch !== '_' ;
}
if ( ch === 'o' ) {
// base 8
index ++ ;
for ( ; index < max ; index ++ ) {
ch = data [ index ] ;
if ( ch === '_' ) continue ;
if ( ! isOctCode ( data . charCodeAt ( index ) ) ) return false ;
hasDigits = true ;
}
return hasDigits && ch !== '_' ;
}
}
// base 10 (except 0)
// value should not start with `_`;
if ( ch === '_' ) return false ;
for ( ; index < max ; index ++ ) {
ch = data [ index ] ;
if ( ch === '_' ) continue ;
if ( ! isDecCode ( data . charCodeAt ( index ) ) ) {
return false ;
}
hasDigits = true ;
}
// Should have digits and should not end with `_`
if ( ! hasDigits || ch === '_' ) return false ;
return true ;
}
function constructYamlInteger ( data ) {
var value = data , sign = 1 , ch ;
if ( value . indexOf ( '_' ) !== - 1 ) {
value = value . replace ( /_/g , '' ) ;
}
ch = value [ 0 ] ;
if ( ch === '-' || ch === '+' ) {
if ( ch === '-' ) sign = - 1 ;
value = value . slice ( 1 ) ;
ch = value [ 0 ] ;
}
if ( value === '0' ) return 0 ;
if ( ch === '0' ) {
if ( value [ 1 ] === 'b' ) return sign * parseInt ( value . slice ( 2 ) , 2 ) ;
if ( value [ 1 ] === 'x' ) return sign * parseInt ( value . slice ( 2 ) , 16 ) ;
if ( value [ 1 ] === 'o' ) return sign * parseInt ( value . slice ( 2 ) , 8 ) ;
}
return sign * parseInt ( value , 10 ) ;
}
function isInteger ( object ) {
return ( Object . prototype . toString . call ( object ) ) === '[object Number]' &&
( object % 1 === 0 && ! common . isNegativeZero ( object ) ) ;
}
module . exports = new Type ( 'tag:yaml.org,2002:int' , {
kind : 'scalar' ,
resolve : resolveYamlInteger ,
construct : constructYamlInteger ,
predicate : isInteger ,
represent : {
binary : function ( obj ) { return obj >= 0 ? '0b' + obj . toString ( 2 ) : '-0b' + obj . toString ( 2 ) . slice ( 1 ) ; } ,
octal : function ( obj ) { return obj >= 0 ? '0o' + obj . toString ( 8 ) : '-0o' + obj . toString ( 8 ) . slice ( 1 ) ; } ,
decimal : function ( obj ) { return obj . toString ( 10 ) ; } ,
/* eslint-disable max-len */
hexadecimal : function ( obj ) { return obj >= 0 ? '0x' + obj . toString ( 16 ) . toUpperCase ( ) : '-0x' + obj . toString ( 16 ) . toUpperCase ( ) . slice ( 1 ) ; }
} ,
defaultStyle : 'decimal' ,
styleAliases : {
binary : [ 2 , 'bin' ] ,
octal : [ 8 , 'oct' ] ,
decimal : [ 10 , 'dec' ] ,
hexadecimal : [ 16 , 'hex' ]
}
} ) ;
/***/ } ) ,
/***/ 150 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
module . exports = new Type ( 'tag:yaml.org,2002:map' , {
kind : 'mapping' ,
construct : function ( data ) { return data !== null ? data : { } ; }
} ) ;
/***/ } ) ,
/***/ 104 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
function resolveYamlMerge ( data ) {
return data === '<<' || data === null ;
}
module . exports = new Type ( 'tag:yaml.org,2002:merge' , {
kind : 'scalar' ,
resolve : resolveYamlMerge
} ) ;
/***/ } ) ,
/***/ 721 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
function resolveYamlNull ( data ) {
if ( data === null ) return true ;
var max = data . length ;
return ( max === 1 && data === '~' ) ||
( max === 4 && ( data === 'null' || data === 'Null' || data === 'NULL' ) ) ;
}
function constructYamlNull ( ) {
return null ;
}
function isNull ( object ) {
return object === null ;
}
module . exports = new Type ( 'tag:yaml.org,2002:null' , {
kind : 'scalar' ,
resolve : resolveYamlNull ,
construct : constructYamlNull ,
predicate : isNull ,
represent : {
canonical : function ( ) { return '~' ; } ,
lowercase : function ( ) { return 'null' ; } ,
uppercase : function ( ) { return 'NULL' ; } ,
camelcase : function ( ) { return 'Null' ; } ,
empty : function ( ) { return '' ; }
} ,
defaultStyle : 'lowercase'
} ) ;
/***/ } ) ,
/***/ 46 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
var _hasOwnProperty = Object . prototype . hasOwnProperty ;
var _toString = Object . prototype . toString ;
function resolveYamlOmap ( data ) {
if ( data === null ) return true ;
var objectKeys = [ ] , index , length , pair , pairKey , pairHasKey ,
object = data ;
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
pair = object [ index ] ;
pairHasKey = false ;
if ( _toString . call ( pair ) !== '[object Object]' ) return false ;
for ( pairKey in pair ) {
if ( _hasOwnProperty . call ( pair , pairKey ) ) {
if ( ! pairHasKey ) pairHasKey = true ;
else return false ;
}
}
if ( ! pairHasKey ) return false ;
if ( objectKeys . indexOf ( pairKey ) === - 1 ) objectKeys . push ( pairKey ) ;
else return false ;
}
return true ;
}
function constructYamlOmap ( data ) {
return data !== null ? data : [ ] ;
}
module . exports = new Type ( 'tag:yaml.org,2002:omap' , {
kind : 'sequence' ,
resolve : resolveYamlOmap ,
construct : constructYamlOmap
} ) ;
/***/ } ) ,
/***/ 860 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
var _toString = Object . prototype . toString ;
function resolveYamlPairs ( data ) {
if ( data === null ) return true ;
var index , length , pair , keys , result ,
object = data ;
result = new Array ( object . length ) ;
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
pair = object [ index ] ;
if ( _toString . call ( pair ) !== '[object Object]' ) return false ;
keys = Object . keys ( pair ) ;
if ( keys . length !== 1 ) return false ;
result [ index ] = [ keys [ 0 ] , pair [ keys [ 0 ] ] ] ;
}
return true ;
}
function constructYamlPairs ( data ) {
if ( data === null ) return [ ] ;
var index , length , pair , keys , result ,
object = data ;
result = new Array ( object . length ) ;
for ( index = 0 , length = object . length ; index < length ; index += 1 ) {
pair = object [ index ] ;
keys = Object . keys ( pair ) ;
result [ index ] = [ keys [ 0 ] , pair [ keys [ 0 ] ] ] ;
}
return result ;
}
module . exports = new Type ( 'tag:yaml.org,2002:pairs' , {
kind : 'sequence' ,
resolve : resolveYamlPairs ,
construct : constructYamlPairs
} ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 546 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
module . exports = new Type ( 'tag:yaml.org,2002:seq' , {
kind : 'sequence' ,
construct : function ( data ) { return data !== null ? data : [ ] ; }
} ) ;
/***/ } ) ,
/***/ 548 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
var _hasOwnProperty = Object . prototype . hasOwnProperty ;
function resolveYamlSet ( data ) {
if ( data === null ) return true ;
var key , object = data ;
for ( key in object ) {
if ( _hasOwnProperty . call ( object , key ) ) {
if ( object [ key ] !== null ) return false ;
}
}
return true ;
}
function constructYamlSet ( data ) {
return data !== null ? data : { } ;
}
module . exports = new Type ( 'tag:yaml.org,2002:set' , {
kind : 'mapping' ,
resolve : resolveYamlSet ,
construct : constructYamlSet
} ) ;
/***/ } ) ,
/***/ 619 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
module . exports = new Type ( 'tag:yaml.org,2002:str' , {
kind : 'scalar' ,
construct : function ( data ) { return data !== null ? data : '' ; }
} ) ;
/***/ } ) ,
/***/ 212 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var Type = _ _nccwpck _require _ _ ( 73 ) ;
var YAML _DATE _REGEXP = new RegExp (
'^([0-9][0-9][0-9][0-9])' + // [1] year
'-([0-9][0-9])' + // [2] month
'-([0-9][0-9])$' ) ; // [3] day
var YAML _TIMESTAMP _REGEXP = new RegExp (
'^([0-9][0-9][0-9][0-9])' + // [1] year
'-([0-9][0-9]?)' + // [2] month
'-([0-9][0-9]?)' + // [3] day
'(?:[Tt]|[ \\t]+)' + // ...
'([0-9][0-9]?)' + // [4] hour
':([0-9][0-9])' + // [5] minute
':([0-9][0-9])' + // [6] second
'(?:\\.([0-9]*))?' + // [7] fraction
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
'(?::([0-9][0-9]))?))?$' ) ; // [11] tz_minute
function resolveYamlTimestamp ( data ) {
if ( data === null ) return false ;
if ( YAML _DATE _REGEXP . exec ( data ) !== null ) return true ;
if ( YAML _TIMESTAMP _REGEXP . exec ( data ) !== null ) return true ;
return false ;
}
function constructYamlTimestamp ( data ) {
var match , year , month , day , hour , minute , second , fraction = 0 ,
delta = null , tz _hour , tz _minute , date ;
match = YAML _DATE _REGEXP . exec ( data ) ;
if ( match === null ) match = YAML _TIMESTAMP _REGEXP . exec ( data ) ;
if ( match === null ) throw new Error ( 'Date resolve error' ) ;
// match: [1] year [2] month [3] day
year = + ( match [ 1 ] ) ;
month = + ( match [ 2 ] ) - 1 ; // JS month starts with 0
day = + ( match [ 3 ] ) ;
if ( ! match [ 4 ] ) { // no hour
return new Date ( Date . UTC ( year , month , day ) ) ;
}
// match: [4] hour [5] minute [6] second [7] fraction
hour = + ( match [ 4 ] ) ;
minute = + ( match [ 5 ] ) ;
second = + ( match [ 6 ] ) ;
if ( match [ 7 ] ) {
fraction = match [ 7 ] . slice ( 0 , 3 ) ;
while ( fraction . length < 3 ) { // milli-seconds
fraction += '0' ;
}
fraction = + fraction ;
}
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
if ( match [ 9 ] ) {
tz _hour = + ( match [ 10 ] ) ;
tz _minute = + ( match [ 11 ] || 0 ) ;
delta = ( tz _hour * 60 + tz _minute ) * 60000 ; // delta in mili-seconds
if ( match [ 9 ] === '-' ) delta = - delta ;
}
date = new Date ( Date . UTC ( year , month , day , hour , minute , second , fraction ) ) ;
if ( delta ) date . setTime ( date . getTime ( ) - delta ) ;
return date ;
}
function representYamlTimestamp ( object /*, style*/ ) {
return object . toISOString ( ) ;
}
module . exports = new Type ( 'tag:yaml.org,2002:timestamp' , {
kind : 'scalar' ,
resolve : resolveYamlTimestamp ,
construct : constructYamlTimestamp ,
instanceOf : Date ,
represent : representYamlTimestamp
} ) ;
/***/ } ) ,
/***/ 294 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
module . exports = _ _nccwpck _require _ _ ( 219 ) ;
/***/ } ) ,
/***/ 219 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
2021-12-24 17:13:55 -05:00
var net = _ _nccwpck _require _ _ ( 808 ) ;
var tls = _ _nccwpck _require _ _ ( 404 ) ;
var http = _ _nccwpck _require _ _ ( 685 ) ;
var https = _ _nccwpck _require _ _ ( 687 ) ;
var events = _ _nccwpck _require _ _ ( 361 ) ;
var assert = _ _nccwpck _require _ _ ( 491 ) ;
var util = _ _nccwpck _require _ _ ( 837 ) ;
2021-10-01 03:17:49 -04:00
exports . httpOverHttp = httpOverHttp ;
exports . httpsOverHttp = httpsOverHttp ;
exports . httpOverHttps = httpOverHttps ;
exports . httpsOverHttps = httpsOverHttps ;
function httpOverHttp ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = http . request ;
return agent ;
}
function httpsOverHttp ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = http . request ;
agent . createSocket = createSecureSocket ;
agent . defaultPort = 443 ;
return agent ;
}
function httpOverHttps ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = https . request ;
return agent ;
}
function httpsOverHttps ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = https . request ;
agent . createSocket = createSecureSocket ;
agent . defaultPort = 443 ;
return agent ;
}
function TunnelingAgent ( options ) {
var self = this ;
self . options = options || { } ;
self . proxyOptions = self . options . proxy || { } ;
self . maxSockets = self . options . maxSockets || http . Agent . defaultMaxSockets ;
self . requests = [ ] ;
self . sockets = [ ] ;
self . on ( 'free' , function onFree ( socket , host , port , localAddress ) {
var options = toOptions ( host , port , localAddress ) ;
for ( var i = 0 , len = self . requests . length ; i < len ; ++ i ) {
var pending = self . requests [ i ] ;
if ( pending . host === options . host && pending . port === options . port ) {
// Detect the request to connect same origin server,
// reuse the connection.
self . requests . splice ( i , 1 ) ;
pending . request . onSocket ( socket ) ;
return ;
}
}
socket . destroy ( ) ;
self . removeSocket ( socket ) ;
} ) ;
}
util . inherits ( TunnelingAgent , events . EventEmitter ) ;
TunnelingAgent . prototype . addRequest = function addRequest ( req , host , port , localAddress ) {
var self = this ;
var options = mergeOptions ( { request : req } , self . options , toOptions ( host , port , localAddress ) ) ;
if ( self . sockets . length >= this . maxSockets ) {
// We are over limit so we'll add it to the queue.
self . requests . push ( options ) ;
return ;
}
// If we are under maxSockets create a new one.
self . createSocket ( options , function ( socket ) {
socket . on ( 'free' , onFree ) ;
socket . on ( 'close' , onCloseOrRemove ) ;
socket . on ( 'agentRemove' , onCloseOrRemove ) ;
req . onSocket ( socket ) ;
function onFree ( ) {
self . emit ( 'free' , socket , options ) ;
}
function onCloseOrRemove ( err ) {
self . removeSocket ( socket ) ;
socket . removeListener ( 'free' , onFree ) ;
socket . removeListener ( 'close' , onCloseOrRemove ) ;
socket . removeListener ( 'agentRemove' , onCloseOrRemove ) ;
}
} ) ;
} ;
TunnelingAgent . prototype . createSocket = function createSocket ( options , cb ) {
var self = this ;
var placeholder = { } ;
self . sockets . push ( placeholder ) ;
var connectOptions = mergeOptions ( { } , self . proxyOptions , {
method : 'CONNECT' ,
path : options . host + ':' + options . port ,
agent : false ,
headers : {
host : options . host + ':' + options . port
}
} ) ;
if ( options . localAddress ) {
connectOptions . localAddress = options . localAddress ;
}
if ( connectOptions . proxyAuth ) {
connectOptions . headers = connectOptions . headers || { } ;
connectOptions . headers [ 'Proxy-Authorization' ] = 'Basic ' +
new Buffer ( connectOptions . proxyAuth ) . toString ( 'base64' ) ;
}
debug ( 'making CONNECT request' ) ;
var connectReq = self . request ( connectOptions ) ;
connectReq . useChunkedEncodingByDefault = false ; // for v0.6
connectReq . once ( 'response' , onResponse ) ; // for v0.6
connectReq . once ( 'upgrade' , onUpgrade ) ; // for v0.6
connectReq . once ( 'connect' , onConnect ) ; // for v0.7 or later
connectReq . once ( 'error' , onError ) ;
connectReq . end ( ) ;
function onResponse ( res ) {
// Very hacky. This is necessary to avoid http-parser leaks.
res . upgrade = true ;
}
function onUpgrade ( res , socket , head ) {
// Hacky.
process . nextTick ( function ( ) {
onConnect ( res , socket , head ) ;
} ) ;
}
function onConnect ( res , socket , head ) {
connectReq . removeAllListeners ( ) ;
socket . removeAllListeners ( ) ;
if ( res . statusCode !== 200 ) {
debug ( 'tunneling socket could not be established, statusCode=%d' ,
res . statusCode ) ;
socket . destroy ( ) ;
var error = new Error ( 'tunneling socket could not be established, ' +
'statusCode=' + res . statusCode ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
return ;
}
if ( head . length > 0 ) {
debug ( 'got illegal response body from proxy' ) ;
socket . destroy ( ) ;
var error = new Error ( 'got illegal response body from proxy' ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
return ;
}
debug ( 'tunneling connection has established' ) ;
self . sockets [ self . sockets . indexOf ( placeholder ) ] = socket ;
return cb ( socket ) ;
}
function onError ( cause ) {
connectReq . removeAllListeners ( ) ;
debug ( 'tunneling socket could not be established, cause=%s\n' ,
cause . message , cause . stack ) ;
var error = new Error ( 'tunneling socket could not be established, ' +
'cause=' + cause . message ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
}
} ;
TunnelingAgent . prototype . removeSocket = function removeSocket ( socket ) {
var pos = this . sockets . indexOf ( socket )
if ( pos === - 1 ) {
return ;
}
this . sockets . splice ( pos , 1 ) ;
var pending = this . requests . shift ( ) ;
if ( pending ) {
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.
this . createSocket ( pending , function ( socket ) {
pending . request . onSocket ( socket ) ;
} ) ;
}
} ;
function createSecureSocket ( options , cb ) {
var self = this ;
TunnelingAgent . prototype . createSocket . call ( self , options , function ( socket ) {
var hostHeader = options . request . getHeader ( 'host' ) ;
var tlsOptions = mergeOptions ( { } , self . options , {
socket : socket ,
servername : hostHeader ? hostHeader . replace ( /:.*$/ , '' ) : options . host
} ) ;
// 0 is dummy port for v0.6
var secureSocket = tls . connect ( 0 , tlsOptions ) ;
self . sockets [ self . sockets . indexOf ( socket ) ] = secureSocket ;
cb ( secureSocket ) ;
} ) ;
}
function toOptions ( host , port , localAddress ) {
if ( typeof host === 'string' ) { // since v0.10
return {
host : host ,
port : port ,
localAddress : localAddress
} ;
}
return host ; // for v0.11 or later
}
function mergeOptions ( target ) {
for ( var i = 1 , len = arguments . length ; i < len ; ++ i ) {
var overrides = arguments [ i ] ;
if ( typeof overrides === 'object' ) {
var keys = Object . keys ( overrides ) ;
for ( var j = 0 , keyLen = keys . length ; j < keyLen ; ++ j ) {
var k = keys [ j ] ;
if ( overrides [ k ] !== undefined ) {
target [ k ] = overrides [ k ] ;
}
}
}
}
return target ;
}
var debug ;
if ( process . env . NODE _DEBUG && /\btunnel\b/ . test ( process . env . NODE _DEBUG ) ) {
debug = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
if ( typeof args [ 0 ] === 'string' ) {
args [ 0 ] = 'TUNNEL: ' + args [ 0 ] ;
} else {
args . unshift ( 'TUNNEL:' ) ;
}
console . error . apply ( console , args ) ;
}
} else {
debug = function ( ) { } ;
}
exports . debug = debug ; // for test
/***/ } ) ,
/***/ 987 :
/***/ ( function ( module , exports ) {
// Underscore.js 1.6.0
// http://underscorejs.org
// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
( function ( ) {
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `exports` on the server.
var root = this ;
// Save the previous value of the `_` variable.
var previousUnderscore = root . _ ;
// Establish the object that gets returned to break out of a loop iteration.
var breaker = { } ;
// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array . prototype , ObjProto = Object . prototype , FuncProto = Function . prototype ;
// Create quick reference variables for speed access to core prototypes.
var
push = ArrayProto . push ,
slice = ArrayProto . slice ,
concat = ArrayProto . concat ,
toString = ObjProto . toString ,
hasOwnProperty = ObjProto . hasOwnProperty ;
// All **ECMAScript 5** native function implementations that we hope to use
// are declared here.
var
nativeForEach = ArrayProto . forEach ,
nativeMap = ArrayProto . map ,
nativeReduce = ArrayProto . reduce ,
nativeReduceRight = ArrayProto . reduceRight ,
nativeFilter = ArrayProto . filter ,
nativeEvery = ArrayProto . every ,
nativeSome = ArrayProto . some ,
nativeIndexOf = ArrayProto . indexOf ,
nativeLastIndexOf = ArrayProto . lastIndexOf ,
nativeIsArray = Array . isArray ,
nativeKeys = Object . keys ,
nativeBind = FuncProto . bind ;
// Create a safe reference to the Underscore object for use below.
var _ = function ( obj ) {
if ( obj instanceof _ ) return obj ;
if ( ! ( this instanceof _ ) ) return new _ ( obj ) ;
this . _wrapped = obj ;
} ;
// Export the Underscore object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `_` as a global object via a string identifier,
// for Closure Compiler "advanced" mode.
if ( true ) {
if ( true && module . exports ) {
exports = module . exports = _ ;
}
exports . _ = _ ;
} else { }
// Current version.
_ . VERSION = '1.6.0' ;
// Collection Functions
// --------------------
// The cornerstone, an `each` implementation, aka `forEach`.
// Handles objects with the built-in `forEach`, arrays, and raw objects.
// Delegates to **ECMAScript 5**'s native `forEach` if available.
var each = _ . each = _ . forEach = function ( obj , iterator , context ) {
if ( obj == null ) return obj ;
if ( nativeForEach && obj . forEach === nativeForEach ) {
obj . forEach ( iterator , context ) ;
} else if ( obj . length === + obj . length ) {
for ( var i = 0 , length = obj . length ; i < length ; i ++ ) {
if ( iterator . call ( context , obj [ i ] , i , obj ) === breaker ) return ;
}
} else {
var keys = _ . keys ( obj ) ;
for ( var i = 0 , length = keys . length ; i < length ; i ++ ) {
if ( iterator . call ( context , obj [ keys [ i ] ] , keys [ i ] , obj ) === breaker ) return ;
}
}
return obj ;
} ;
// Return the results of applying the iterator to each element.
// Delegates to **ECMAScript 5**'s native `map` if available.
_ . map = _ . collect = function ( obj , iterator , context ) {
var results = [ ] ;
if ( obj == null ) return results ;
if ( nativeMap && obj . map === nativeMap ) return obj . map ( iterator , context ) ;
each ( obj , function ( value , index , list ) {
results . push ( iterator . call ( context , value , index , list ) ) ;
} ) ;
return results ;
} ;
var reduceError = 'Reduce of empty array with no initial value' ;
// **Reduce** builds up a single result from a list of values, aka `inject`,
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
_ . reduce = _ . foldl = _ . inject = function ( obj , iterator , memo , context ) {
var initial = arguments . length > 2 ;
if ( obj == null ) obj = [ ] ;
if ( nativeReduce && obj . reduce === nativeReduce ) {
if ( context ) iterator = _ . bind ( iterator , context ) ;
return initial ? obj . reduce ( iterator , memo ) : obj . reduce ( iterator ) ;
}
each ( obj , function ( value , index , list ) {
if ( ! initial ) {
memo = value ;
initial = true ;
} else {
memo = iterator . call ( context , memo , value , index , list ) ;
}
} ) ;
if ( ! initial ) throw new TypeError ( reduceError ) ;
return memo ;
} ;
// The right-associative version of reduce, also known as `foldr`.
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
_ . reduceRight = _ . foldr = function ( obj , iterator , memo , context ) {
var initial = arguments . length > 2 ;
if ( obj == null ) obj = [ ] ;
if ( nativeReduceRight && obj . reduceRight === nativeReduceRight ) {
if ( context ) iterator = _ . bind ( iterator , context ) ;
return initial ? obj . reduceRight ( iterator , memo ) : obj . reduceRight ( iterator ) ;
}
var length = obj . length ;
if ( length !== + length ) {
var keys = _ . keys ( obj ) ;
length = keys . length ;
}
each ( obj , function ( value , index , list ) {
index = keys ? keys [ -- length ] : -- length ;
if ( ! initial ) {
memo = obj [ index ] ;
initial = true ;
} else {
memo = iterator . call ( context , memo , obj [ index ] , index , list ) ;
}
} ) ;
if ( ! initial ) throw new TypeError ( reduceError ) ;
return memo ;
} ;
// Return the first value which passes a truth test. Aliased as `detect`.
_ . find = _ . detect = function ( obj , predicate , context ) {
var result ;
any ( obj , function ( value , index , list ) {
if ( predicate . call ( context , value , index , list ) ) {
result = value ;
return true ;
}
} ) ;
return result ;
} ;
// Return all the elements that pass a truth test.
// Delegates to **ECMAScript 5**'s native `filter` if available.
// Aliased as `select`.
_ . filter = _ . select = function ( obj , predicate , context ) {
var results = [ ] ;
if ( obj == null ) return results ;
if ( nativeFilter && obj . filter === nativeFilter ) return obj . filter ( predicate , context ) ;
each ( obj , function ( value , index , list ) {
if ( predicate . call ( context , value , index , list ) ) results . push ( value ) ;
} ) ;
return results ;
} ;
// Return all the elements for which a truth test fails.
_ . reject = function ( obj , predicate , context ) {
return _ . filter ( obj , function ( value , index , list ) {
return ! predicate . call ( context , value , index , list ) ;
} , context ) ;
} ;
// Determine whether all of the elements match a truth test.
// Delegates to **ECMAScript 5**'s native `every` if available.
// Aliased as `all`.
_ . every = _ . all = function ( obj , predicate , context ) {
predicate || ( predicate = _ . identity ) ;
var result = true ;
if ( obj == null ) return result ;
if ( nativeEvery && obj . every === nativeEvery ) return obj . every ( predicate , context ) ;
each ( obj , function ( value , index , list ) {
if ( ! ( result = result && predicate . call ( context , value , index , list ) ) ) return breaker ;
} ) ;
return ! ! result ;
} ;
// Determine if at least one element in the object matches a truth test.
// Delegates to **ECMAScript 5**'s native `some` if available.
// Aliased as `any`.
var any = _ . some = _ . any = function ( obj , predicate , context ) {
predicate || ( predicate = _ . identity ) ;
var result = false ;
if ( obj == null ) return result ;
if ( nativeSome && obj . some === nativeSome ) return obj . some ( predicate , context ) ;
each ( obj , function ( value , index , list ) {
if ( result || ( result = predicate . call ( context , value , index , list ) ) ) return breaker ;
} ) ;
return ! ! result ;
} ;
// Determine if the array or object contains a given value (using `===`).
// Aliased as `include`.
_ . contains = _ . include = function ( obj , target ) {
if ( obj == null ) return false ;
if ( nativeIndexOf && obj . indexOf === nativeIndexOf ) return obj . indexOf ( target ) != - 1 ;
return any ( obj , function ( value ) {
return value === target ;
} ) ;
} ;
// Invoke a method (with arguments) on every item in a collection.
_ . invoke = function ( obj , method ) {
var args = slice . call ( arguments , 2 ) ;
var isFunc = _ . isFunction ( method ) ;
return _ . map ( obj , function ( value ) {
return ( isFunc ? method : value [ method ] ) . apply ( value , args ) ;
} ) ;
} ;
// Convenience version of a common use case of `map`: fetching a property.
_ . pluck = function ( obj , key ) {
return _ . map ( obj , _ . property ( key ) ) ;
} ;
// Convenience version of a common use case of `filter`: selecting only objects
// containing specific `key:value` pairs.
_ . where = function ( obj , attrs ) {
return _ . filter ( obj , _ . matches ( attrs ) ) ;
} ;
// Convenience version of a common use case of `find`: getting the first object
// containing specific `key:value` pairs.
_ . findWhere = function ( obj , attrs ) {
return _ . find ( obj , _ . matches ( attrs ) ) ;
} ;
// Return the maximum element or (element-based computation).
// Can't optimize arrays of integers longer than 65,535 elements.
// See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797)
_ . max = function ( obj , iterator , context ) {
if ( ! iterator && _ . isArray ( obj ) && obj [ 0 ] === + obj [ 0 ] && obj . length < 65535 ) {
return Math . max . apply ( Math , obj ) ;
}
var result = - Infinity , lastComputed = - Infinity ;
each ( obj , function ( value , index , list ) {
var computed = iterator ? iterator . call ( context , value , index , list ) : value ;
if ( computed > lastComputed ) {
result = value ;
lastComputed = computed ;
}
} ) ;
return result ;
} ;
// Return the minimum element (or element-based computation).
_ . min = function ( obj , iterator , context ) {
if ( ! iterator && _ . isArray ( obj ) && obj [ 0 ] === + obj [ 0 ] && obj . length < 65535 ) {
return Math . min . apply ( Math , obj ) ;
}
var result = Infinity , lastComputed = Infinity ;
each ( obj , function ( value , index , list ) {
var computed = iterator ? iterator . call ( context , value , index , list ) : value ;
if ( computed < lastComputed ) {
result = value ;
lastComputed = computed ;
}
} ) ;
return result ;
} ;
// Shuffle an array, using the modern version of the
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher– Yates_shuffle).
_ . shuffle = function ( obj ) {
var rand ;
var index = 0 ;
var shuffled = [ ] ;
each ( obj , function ( value ) {
rand = _ . random ( index ++ ) ;
shuffled [ index - 1 ] = shuffled [ rand ] ;
shuffled [ rand ] = value ;
} ) ;
return shuffled ;
} ;
// Sample **n** random values from a collection.
// If **n** is not specified, returns a single random element.
// The internal `guard` argument allows it to work with `map`.
_ . sample = function ( obj , n , guard ) {
if ( n == null || guard ) {
if ( obj . length !== + obj . length ) obj = _ . values ( obj ) ;
return obj [ _ . random ( obj . length - 1 ) ] ;
}
return _ . shuffle ( obj ) . slice ( 0 , Math . max ( 0 , n ) ) ;
} ;
// An internal function to generate lookup iterators.
var lookupIterator = function ( value ) {
if ( value == null ) return _ . identity ;
if ( _ . isFunction ( value ) ) return value ;
return _ . property ( value ) ;
} ;
// Sort the object's values by a criterion produced by an iterator.
_ . sortBy = function ( obj , iterator , context ) {
iterator = lookupIterator ( iterator ) ;
return _ . pluck ( _ . map ( obj , function ( value , index , list ) {
return {
value : value ,
index : index ,
criteria : iterator . call ( context , value , index , list )
} ;
} ) . sort ( function ( left , right ) {
var a = left . criteria ;
var b = right . criteria ;
if ( a !== b ) {
if ( a > b || a === void 0 ) return 1 ;
if ( a < b || b === void 0 ) return - 1 ;
}
return left . index - right . index ;
} ) , 'value' ) ;
} ;
// An internal function used for aggregate "group by" operations.
var group = function ( behavior ) {
return function ( obj , iterator , context ) {
var result = { } ;
iterator = lookupIterator ( iterator ) ;
each ( obj , function ( value , index ) {
var key = iterator . call ( context , value , index , obj ) ;
behavior ( result , key , value ) ;
} ) ;
return result ;
} ;
} ;
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_ . groupBy = group ( function ( result , key , value ) {
_ . has ( result , key ) ? result [ key ] . push ( value ) : result [ key ] = [ value ] ;
} ) ;
// Indexes the object's values by a criterion, similar to `groupBy`, but for
// when you know that your index values will be unique.
_ . indexBy = group ( function ( result , key , value ) {
result [ key ] = value ;
} ) ;
// Counts instances of an object that group by a certain criterion. Pass
// either a string attribute to count by, or a function that returns the
// criterion.
_ . countBy = group ( function ( result , key ) {
_ . has ( result , key ) ? result [ key ] ++ : result [ key ] = 1 ;
} ) ;
// Use a comparator function to figure out the smallest index at which
// an object should be inserted so as to maintain order. Uses binary search.
_ . sortedIndex = function ( array , obj , iterator , context ) {
iterator = lookupIterator ( iterator ) ;
var value = iterator . call ( context , obj ) ;
var low = 0 , high = array . length ;
while ( low < high ) {
var mid = ( low + high ) >>> 1 ;
iterator . call ( context , array [ mid ] ) < value ? low = mid + 1 : high = mid ;
}
return low ;
} ;
// Safely create a real, live array from anything iterable.
_ . toArray = function ( obj ) {
if ( ! obj ) return [ ] ;
if ( _ . isArray ( obj ) ) return slice . call ( obj ) ;
if ( obj . length === + obj . length ) return _ . map ( obj , _ . identity ) ;
return _ . values ( obj ) ;
} ;
// Return the number of elements in an object.
_ . size = function ( obj ) {
if ( obj == null ) return 0 ;
return ( obj . length === + obj . length ) ? obj . length : _ . keys ( obj ) . length ;
} ;
// Array Functions
// ---------------
// Get the first element of an array. Passing **n** will return the first N
// values in the array. Aliased as `head` and `take`. The **guard** check
// allows it to work with `_.map`.
_ . first = _ . head = _ . take = function ( array , n , guard ) {
if ( array == null ) return void 0 ;
if ( ( n == null ) || guard ) return array [ 0 ] ;
if ( n < 0 ) return [ ] ;
return slice . call ( array , 0 , n ) ;
} ;
// Returns everything but the last entry of the array. Especially useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N. The **guard** check allows it to work with
// `_.map`.
_ . initial = function ( array , n , guard ) {
return slice . call ( array , 0 , array . length - ( ( n == null ) || guard ? 1 : n ) ) ;
} ;
// Get the last element of an array. Passing **n** will return the last N
// values in the array. The **guard** check allows it to work with `_.map`.
_ . last = function ( array , n , guard ) {
if ( array == null ) return void 0 ;
if ( ( n == null ) || guard ) return array [ array . length - 1 ] ;
return slice . call ( array , Math . max ( array . length - n , 0 ) ) ;
} ;
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
// Especially useful on the arguments object. Passing an **n** will return
// the rest N values in the array. The **guard**
// check allows it to work with `_.map`.
_ . rest = _ . tail = _ . drop = function ( array , n , guard ) {
return slice . call ( array , ( n == null ) || guard ? 1 : n ) ;
} ;
// Trim out all falsy values from an array.
_ . compact = function ( array ) {
return _ . filter ( array , _ . identity ) ;
} ;
// Internal implementation of a recursive `flatten` function.
var flatten = function ( input , shallow , output ) {
if ( shallow && _ . every ( input , _ . isArray ) ) {
return concat . apply ( output , input ) ;
}
each ( input , function ( value ) {
if ( _ . isArray ( value ) || _ . isArguments ( value ) ) {
shallow ? push . apply ( output , value ) : flatten ( value , shallow , output ) ;
} else {
output . push ( value ) ;
}
} ) ;
return output ;
} ;
// Flatten out an array, either recursively (by default), or just one level.
_ . flatten = function ( array , shallow ) {
return flatten ( array , shallow , [ ] ) ;
} ;
// Return a version of the array that does not contain the specified value(s).
_ . without = function ( array ) {
return _ . difference ( array , slice . call ( arguments , 1 ) ) ;
} ;
// Split an array into two arrays: one whose elements all satisfy the given
// predicate, and one whose elements all do not satisfy the predicate.
_ . partition = function ( array , predicate ) {
var pass = [ ] , fail = [ ] ;
each ( array , function ( elem ) {
( predicate ( elem ) ? pass : fail ) . push ( elem ) ;
} ) ;
return [ pass , fail ] ;
} ;
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// Aliased as `unique`.
_ . uniq = _ . unique = function ( array , isSorted , iterator , context ) {
if ( _ . isFunction ( isSorted ) ) {
context = iterator ;
iterator = isSorted ;
isSorted = false ;
}
var initial = iterator ? _ . map ( array , iterator , context ) : array ;
var results = [ ] ;
var seen = [ ] ;
each ( initial , function ( value , index ) {
if ( isSorted ? ( ! index || seen [ seen . length - 1 ] !== value ) : ! _ . contains ( seen , value ) ) {
seen . push ( value ) ;
results . push ( array [ index ] ) ;
}
} ) ;
return results ;
} ;
// Produce an array that contains the union: each distinct element from all of
// the passed-in arrays.
_ . union = function ( ) {
return _ . uniq ( _ . flatten ( arguments , true ) ) ;
} ;
// Produce an array that contains every item shared between all the
// passed-in arrays.
_ . intersection = function ( array ) {
var rest = slice . call ( arguments , 1 ) ;
return _ . filter ( _ . uniq ( array ) , function ( item ) {
return _ . every ( rest , function ( other ) {
return _ . contains ( other , item ) ;
} ) ;
} ) ;
} ;
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_ . difference = function ( array ) {
var rest = concat . apply ( ArrayProto , slice . call ( arguments , 1 ) ) ;
return _ . filter ( array , function ( value ) { return ! _ . contains ( rest , value ) ; } ) ;
} ;
// Zip together multiple lists into a single array -- elements that share
// an index go together.
_ . zip = function ( ) {
var length = _ . max ( _ . pluck ( arguments , 'length' ) . concat ( 0 ) ) ;
var results = new Array ( length ) ;
for ( var i = 0 ; i < length ; i ++ ) {
results [ i ] = _ . pluck ( arguments , '' + i ) ;
}
return results ;
} ;
// Converts lists into objects. Pass either a single array of `[key, value]`
// pairs, or two parallel arrays of the same length -- one of keys, and one of
// the corresponding values.
_ . object = function ( list , values ) {
if ( list == null ) return { } ;
var result = { } ;
for ( var i = 0 , length = list . length ; i < length ; i ++ ) {
if ( values ) {
result [ list [ i ] ] = values [ i ] ;
} else {
result [ list [ i ] [ 0 ] ] = list [ i ] [ 1 ] ;
}
}
return result ;
} ;
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
// we need this function. Return the position of the first occurrence of an
// item in an array, or -1 if the item is not included in the array.
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
// If the array is large and already in sort order, pass `true`
// for **isSorted** to use binary search.
_ . indexOf = function ( array , item , isSorted ) {
if ( array == null ) return - 1 ;
var i = 0 , length = array . length ;
if ( isSorted ) {
if ( typeof isSorted == 'number' ) {
i = ( isSorted < 0 ? Math . max ( 0 , length + isSorted ) : isSorted ) ;
} else {
i = _ . sortedIndex ( array , item ) ;
return array [ i ] === item ? i : - 1 ;
}
}
if ( nativeIndexOf && array . indexOf === nativeIndexOf ) return array . indexOf ( item , isSorted ) ;
for ( ; i < length ; i ++ ) if ( array [ i ] === item ) return i ;
return - 1 ;
} ;
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
_ . lastIndexOf = function ( array , item , from ) {
if ( array == null ) return - 1 ;
var hasIndex = from != null ;
if ( nativeLastIndexOf && array . lastIndexOf === nativeLastIndexOf ) {
return hasIndex ? array . lastIndexOf ( item , from ) : array . lastIndexOf ( item ) ;
}
var i = ( hasIndex ? from : array . length ) ;
while ( i -- ) if ( array [ i ] === item ) return i ;
return - 1 ;
} ;
// Generate an integer Array containing an arithmetic progression. A port of
// the native Python `range()` function. See
// [the Python documentation](http://docs.python.org/library/functions.html#range).
_ . range = function ( start , stop , step ) {
if ( arguments . length <= 1 ) {
stop = start || 0 ;
start = 0 ;
}
step = arguments [ 2 ] || 1 ;
var length = Math . max ( Math . ceil ( ( stop - start ) / step ) , 0 ) ;
var idx = 0 ;
var range = new Array ( length ) ;
while ( idx < length ) {
range [ idx ++ ] = start ;
start += step ;
}
return range ;
} ;
// Function (ahem) Functions
// ------------------
// Reusable constructor function for prototype setting.
var ctor = function ( ) { } ;
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
// available.
_ . bind = function ( func , context ) {
var args , bound ;
if ( nativeBind && func . bind === nativeBind ) return nativeBind . apply ( func , slice . call ( arguments , 1 ) ) ;
if ( ! _ . isFunction ( func ) ) throw new TypeError ;
args = slice . call ( arguments , 2 ) ;
return bound = function ( ) {
if ( ! ( this instanceof bound ) ) return func . apply ( context , args . concat ( slice . call ( arguments ) ) ) ;
ctor . prototype = func . prototype ;
var self = new ctor ;
ctor . prototype = null ;
var result = func . apply ( self , args . concat ( slice . call ( arguments ) ) ) ;
if ( Object ( result ) === result ) return result ;
return self ;
} ;
} ;
// Partially apply a function by creating a version that has had some of its
// arguments pre-filled, without changing its dynamic `this` context. _ acts
// as a placeholder, allowing any combination of arguments to be pre-filled.
_ . partial = function ( func ) {
var boundArgs = slice . call ( arguments , 1 ) ;
return function ( ) {
var position = 0 ;
var args = boundArgs . slice ( ) ;
for ( var i = 0 , length = args . length ; i < length ; i ++ ) {
if ( args [ i ] === _ ) args [ i ] = arguments [ position ++ ] ;
}
while ( position < arguments . length ) args . push ( arguments [ position ++ ] ) ;
return func . apply ( this , args ) ;
} ;
} ;
// Bind a number of an object's methods to that object. Remaining arguments
// are the method names to be bound. Useful for ensuring that all callbacks
// defined on an object belong to it.
_ . bindAll = function ( obj ) {
var funcs = slice . call ( arguments , 1 ) ;
if ( funcs . length === 0 ) throw new Error ( 'bindAll must be passed function names' ) ;
each ( funcs , function ( f ) { obj [ f ] = _ . bind ( obj [ f ] , obj ) ; } ) ;
return obj ;
} ;
// Memoize an expensive function by storing its results.
_ . memoize = function ( func , hasher ) {
var memo = { } ;
hasher || ( hasher = _ . identity ) ;
return function ( ) {
var key = hasher . apply ( this , arguments ) ;
return _ . has ( memo , key ) ? memo [ key ] : ( memo [ key ] = func . apply ( this , arguments ) ) ;
} ;
} ;
// Delays a function for the given number of milliseconds, and then calls
// it with the arguments supplied.
_ . delay = function ( func , wait ) {
var args = slice . call ( arguments , 2 ) ;
return setTimeout ( function ( ) { return func . apply ( null , args ) ; } , wait ) ;
} ;
// Defers a function, scheduling it to run after the current call stack has
// cleared.
_ . defer = function ( func ) {
return _ . delay . apply ( _ , [ func , 1 ] . concat ( slice . call ( arguments , 1 ) ) ) ;
} ;
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `{leading: false}`. To disable execution on the trailing edge, ditto.
_ . throttle = function ( func , wait , options ) {
var context , args , result ;
var timeout = null ;
var previous = 0 ;
options || ( options = { } ) ;
var later = function ( ) {
previous = options . leading === false ? 0 : _ . now ( ) ;
timeout = null ;
result = func . apply ( context , args ) ;
context = args = null ;
} ;
return function ( ) {
var now = _ . now ( ) ;
if ( ! previous && options . leading === false ) previous = now ;
var remaining = wait - ( now - previous ) ;
context = this ;
args = arguments ;
if ( remaining <= 0 ) {
clearTimeout ( timeout ) ;
timeout = null ;
previous = now ;
result = func . apply ( context , args ) ;
context = args = null ;
} else if ( ! timeout && options . trailing !== false ) {
timeout = setTimeout ( later , remaining ) ;
}
return result ;
} ;
} ;
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
_ . debounce = function ( func , wait , immediate ) {
var timeout , args , context , timestamp , result ;
var later = function ( ) {
var last = _ . now ( ) - timestamp ;
if ( last < wait ) {
timeout = setTimeout ( later , wait - last ) ;
} else {
timeout = null ;
if ( ! immediate ) {
result = func . apply ( context , args ) ;
context = args = null ;
}
}
} ;
return function ( ) {
context = this ;
args = arguments ;
timestamp = _ . now ( ) ;
var callNow = immediate && ! timeout ;
if ( ! timeout ) {
timeout = setTimeout ( later , wait ) ;
}
if ( callNow ) {
result = func . apply ( context , args ) ;
context = args = null ;
}
return result ;
} ;
} ;
// Returns a function that will be executed at most one time, no matter how
// often you call it. Useful for lazy initialization.
_ . once = function ( func ) {
var ran = false , memo ;
return function ( ) {
if ( ran ) return memo ;
ran = true ;
memo = func . apply ( this , arguments ) ;
func = null ;
return memo ;
} ;
} ;
// Returns the first function passed as an argument to the second,
// allowing you to adjust arguments, run code before and after, and
// conditionally execute the original function.
_ . wrap = function ( func , wrapper ) {
return _ . partial ( wrapper , func ) ;
} ;
// Returns a function that is the composition of a list of functions, each
// consuming the return value of the function that follows.
_ . compose = function ( ) {
var funcs = arguments ;
return function ( ) {
var args = arguments ;
for ( var i = funcs . length - 1 ; i >= 0 ; i -- ) {
args = [ funcs [ i ] . apply ( this , args ) ] ;
}
return args [ 0 ] ;
} ;
} ;
// Returns a function that will only be executed after being called N times.
_ . after = function ( times , func ) {
return function ( ) {
if ( -- times < 1 ) {
return func . apply ( this , arguments ) ;
}
} ;
} ;
// Object Functions
// ----------------
// Retrieve the names of an object's properties.
// Delegates to **ECMAScript 5**'s native `Object.keys`
_ . keys = function ( obj ) {
if ( ! _ . isObject ( obj ) ) return [ ] ;
if ( nativeKeys ) return nativeKeys ( obj ) ;
var keys = [ ] ;
for ( var key in obj ) if ( _ . has ( obj , key ) ) keys . push ( key ) ;
return keys ;
} ;
// Retrieve the values of an object's properties.
_ . values = function ( obj ) {
var keys = _ . keys ( obj ) ;
var length = keys . length ;
var values = new Array ( length ) ;
for ( var i = 0 ; i < length ; i ++ ) {
values [ i ] = obj [ keys [ i ] ] ;
}
return values ;
} ;
// Convert an object into a list of `[key, value]` pairs.
_ . pairs = function ( obj ) {
var keys = _ . keys ( obj ) ;
var length = keys . length ;
var pairs = new Array ( length ) ;
for ( var i = 0 ; i < length ; i ++ ) {
pairs [ i ] = [ keys [ i ] , obj [ keys [ i ] ] ] ;
}
return pairs ;
} ;
// Invert the keys and values of an object. The values must be serializable.
_ . invert = function ( obj ) {
var result = { } ;
var keys = _ . keys ( obj ) ;
for ( var i = 0 , length = keys . length ; i < length ; i ++ ) {
result [ obj [ keys [ i ] ] ] = keys [ i ] ;
}
return result ;
} ;
// Return a sorted list of the function names available on the object.
// Aliased as `methods`
_ . functions = _ . methods = function ( obj ) {
var names = [ ] ;
for ( var key in obj ) {
if ( _ . isFunction ( obj [ key ] ) ) names . push ( key ) ;
}
return names . sort ( ) ;
} ;
// Extend a given object with all the properties in passed-in object(s).
_ . extend = function ( obj ) {
each ( slice . call ( arguments , 1 ) , function ( source ) {
if ( source ) {
for ( var prop in source ) {
obj [ prop ] = source [ prop ] ;
}
}
} ) ;
return obj ;
} ;
// Return a copy of the object only containing the whitelisted properties.
_ . pick = function ( obj ) {
var copy = { } ;
var keys = concat . apply ( ArrayProto , slice . call ( arguments , 1 ) ) ;
each ( keys , function ( key ) {
if ( key in obj ) copy [ key ] = obj [ key ] ;
} ) ;
return copy ;
} ;
// Return a copy of the object without the blacklisted properties.
_ . omit = function ( obj ) {
var copy = { } ;
var keys = concat . apply ( ArrayProto , slice . call ( arguments , 1 ) ) ;
for ( var key in obj ) {
if ( ! _ . contains ( keys , key ) ) copy [ key ] = obj [ key ] ;
}
return copy ;
} ;
// Fill in a given object with default properties.
_ . defaults = function ( obj ) {
each ( slice . call ( arguments , 1 ) , function ( source ) {
if ( source ) {
for ( var prop in source ) {
if ( obj [ prop ] === void 0 ) obj [ prop ] = source [ prop ] ;
}
}
} ) ;
return obj ;
} ;
// Create a (shallow-cloned) duplicate of an object.
_ . clone = function ( obj ) {
if ( ! _ . isObject ( obj ) ) return obj ;
return _ . isArray ( obj ) ? obj . slice ( ) : _ . extend ( { } , obj ) ;
} ;
// Invokes interceptor with the obj, and then returns obj.
// The primary purpose of this method is to "tap into" a method chain, in
// order to perform operations on intermediate results within the chain.
_ . tap = function ( obj , interceptor ) {
interceptor ( obj ) ;
return obj ;
} ;
// Internal recursive comparison function for `isEqual`.
var eq = function ( a , b , aStack , bStack ) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if ( a === b ) return a !== 0 || 1 / a == 1 / b ;
// A strict comparison is necessary because `null == undefined`.
if ( a == null || b == null ) return a === b ;
// Unwrap any wrapped objects.
if ( a instanceof _ ) a = a . _wrapped ;
if ( b instanceof _ ) b = b . _wrapped ;
// Compare `[[Class]]` names.
var className = toString . call ( a ) ;
if ( className != toString . call ( b ) ) return false ;
switch ( className ) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]' :
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return a == String ( b ) ;
case '[object Number]' :
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != + a ? b != + b : ( a == 0 ? 1 / a == 1 / b : a == + b ) ;
case '[object Date]' :
case '[object Boolean]' :
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return + a == + b ;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]' :
return a . source == b . source &&
a . global == b . global &&
a . multiline == b . multiline &&
a . ignoreCase == b . ignoreCase ;
}
if ( typeof a != 'object' || typeof b != 'object' ) return false ;
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack . length ;
while ( length -- ) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if ( aStack [ length ] == a ) return bStack [ length ] == b ;
}
// Objects with different constructors are not equivalent, but `Object`s
// from different frames are.
var aCtor = a . constructor , bCtor = b . constructor ;
if ( aCtor !== bCtor && ! ( _ . isFunction ( aCtor ) && ( aCtor instanceof aCtor ) &&
_ . isFunction ( bCtor ) && ( bCtor instanceof bCtor ) )
&& ( 'constructor' in a && 'constructor' in b ) ) {
return false ;
}
// Add the first object to the stack of traversed objects.
aStack . push ( a ) ;
bStack . push ( b ) ;
var size = 0 , result = true ;
// Recursively compare objects and arrays.
if ( className == '[object Array]' ) {
// Compare array lengths to determine if a deep comparison is necessary.
size = a . length ;
result = size == b . length ;
if ( result ) {
// Deep compare the contents, ignoring non-numeric properties.
while ( size -- ) {
if ( ! ( result = eq ( a [ size ] , b [ size ] , aStack , bStack ) ) ) break ;
}
}
} else {
// Deep compare objects.
for ( var key in a ) {
if ( _ . has ( a , key ) ) {
// Count the expected number of properties.
size ++ ;
// Deep compare each member.
if ( ! ( result = _ . has ( b , key ) && eq ( a [ key ] , b [ key ] , aStack , bStack ) ) ) break ;
}
}
// Ensure that both objects contain the same number of properties.
if ( result ) {
for ( key in b ) {
if ( _ . has ( b , key ) && ! ( size -- ) ) break ;
}
result = ! size ;
}
}
// Remove the first object from the stack of traversed objects.
aStack . pop ( ) ;
bStack . pop ( ) ;
return result ;
} ;
// Perform a deep comparison to check if two objects are equal.
_ . isEqual = function ( a , b ) {
return eq ( a , b , [ ] , [ ] ) ;
} ;
// Is a given array, string, or object empty?
// An "empty" object has no enumerable own-properties.
_ . isEmpty = function ( obj ) {
if ( obj == null ) return true ;
if ( _ . isArray ( obj ) || _ . isString ( obj ) ) return obj . length === 0 ;
for ( var key in obj ) if ( _ . has ( obj , key ) ) return false ;
return true ;
} ;
// Is a given value a DOM element?
_ . isElement = function ( obj ) {
return ! ! ( obj && obj . nodeType === 1 ) ;
} ;
// Is a given value an array?
// Delegates to ECMA5's native Array.isArray
_ . isArray = nativeIsArray || function ( obj ) {
return toString . call ( obj ) == '[object Array]' ;
} ;
// Is a given variable an object?
_ . isObject = function ( obj ) {
return obj === Object ( obj ) ;
} ;
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
each ( [ 'Arguments' , 'Function' , 'String' , 'Number' , 'Date' , 'RegExp' ] , function ( name ) {
_ [ 'is' + name ] = function ( obj ) {
return toString . call ( obj ) == '[object ' + name + ']' ;
} ;
} ) ;
// Define a fallback version of the method in browsers (ahem, IE), where
// there isn't any inspectable "Arguments" type.
if ( ! _ . isArguments ( arguments ) ) {
_ . isArguments = function ( obj ) {
return ! ! ( obj && _ . has ( obj , 'callee' ) ) ;
} ;
}
// Optimize `isFunction` if appropriate.
if ( true ) {
_ . isFunction = function ( obj ) {
return typeof obj === 'function' ;
} ;
}
// Is a given object a finite number?
_ . isFinite = function ( obj ) {
return isFinite ( obj ) && ! isNaN ( parseFloat ( obj ) ) ;
} ;
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
_ . isNaN = function ( obj ) {
return _ . isNumber ( obj ) && obj != + obj ;
} ;
// Is a given value a boolean?
_ . isBoolean = function ( obj ) {
return obj === true || obj === false || toString . call ( obj ) == '[object Boolean]' ;
} ;
// Is a given value equal to null?
_ . isNull = function ( obj ) {
return obj === null ;
} ;
// Is a given variable undefined?
_ . isUndefined = function ( obj ) {
return obj === void 0 ;
} ;
// Shortcut function for checking if an object has a given property directly
// on itself (in other words, not on a prototype).
_ . has = function ( obj , key ) {
return hasOwnProperty . call ( obj , key ) ;
} ;
// Utility Functions
// -----------------
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
// previous owner. Returns a reference to the Underscore object.
_ . noConflict = function ( ) {
root . _ = previousUnderscore ;
return this ;
} ;
// Keep the identity function around for default iterators.
_ . identity = function ( value ) {
return value ;
} ;
_ . constant = function ( value ) {
return function ( ) {
return value ;
} ;
} ;
_ . property = function ( key ) {
return function ( obj ) {
return obj [ key ] ;
} ;
} ;
// Returns a predicate for checking whether an object has a given set of `key:value` pairs.
_ . matches = function ( attrs ) {
return function ( obj ) {
if ( obj === attrs ) return true ; //avoid comparing an object to itself.
for ( var key in attrs ) {
if ( attrs [ key ] !== obj [ key ] )
return false ;
}
return true ;
}
} ;
// Run a function **n** times.
_ . times = function ( n , iterator , context ) {
var accum = Array ( Math . max ( 0 , n ) ) ;
for ( var i = 0 ; i < n ; i ++ ) accum [ i ] = iterator . call ( context , i ) ;
return accum ;
} ;
// Return a random integer between min and max (inclusive).
_ . random = function ( min , max ) {
if ( max == null ) {
max = min ;
min = 0 ;
}
return min + Math . floor ( Math . random ( ) * ( max - min + 1 ) ) ;
} ;
// A (possibly faster) way to get the current timestamp as an integer.
_ . now = Date . now || function ( ) { return new Date ( ) . getTime ( ) ; } ;
// List of HTML entities for escaping.
var entityMap = {
escape : {
'&' : '&' ,
'<' : '<' ,
'>' : '>' ,
'"' : '"' ,
"'" : '''
}
} ;
entityMap . unescape = _ . invert ( entityMap . escape ) ;
// Regexes containing the keys and values listed immediately above.
var entityRegexes = {
escape : new RegExp ( '[' + _ . keys ( entityMap . escape ) . join ( '' ) + ']' , 'g' ) ,
unescape : new RegExp ( '(' + _ . keys ( entityMap . unescape ) . join ( '|' ) + ')' , 'g' )
} ;
// Functions for escaping and unescaping strings to/from HTML interpolation.
_ . each ( [ 'escape' , 'unescape' ] , function ( method ) {
_ [ method ] = function ( string ) {
if ( string == null ) return '' ;
return ( '' + string ) . replace ( entityRegexes [ method ] , function ( match ) {
return entityMap [ method ] [ match ] ;
} ) ;
} ;
} ) ;
// If the value of the named `property` is a function then invoke it with the
// `object` as context; otherwise, return it.
_ . result = function ( object , property ) {
if ( object == null ) return void 0 ;
var value = object [ property ] ;
return _ . isFunction ( value ) ? value . call ( object ) : value ;
} ;
// Add your own custom functions to the Underscore object.
_ . mixin = function ( obj ) {
each ( _ . functions ( obj ) , function ( name ) {
var func = _ [ name ] = obj [ name ] ;
_ . prototype [ name ] = function ( ) {
var args = [ this . _wrapped ] ;
push . apply ( args , arguments ) ;
return result . call ( this , func . apply ( _ , args ) ) ;
} ;
} ) ;
} ;
// Generate a unique integer id (unique within the entire client session).
// Useful for temporary DOM ids.
var idCounter = 0 ;
_ . uniqueId = function ( prefix ) {
var id = ++ idCounter + '' ;
return prefix ? prefix + id : id ;
} ;
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_ . templateSettings = {
evaluate : /<%([\s\S]+?)%>/g ,
interpolate : /<%=([\s\S]+?)%>/g ,
escape : /<%-([\s\S]+?)%>/g
} ;
// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var noMatch = /(.)^/ ;
// Certain characters need to be escaped so that they can be put into a
// string literal.
var escapes = {
"'" : "'" ,
'\\' : '\\' ,
'\r' : 'r' ,
'\n' : 'n' ,
'\t' : 't' ,
'\u2028' : 'u2028' ,
'\u2029' : 'u2029'
} ;
var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g ;
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_ . template = function ( text , data , settings ) {
var render ;
settings = _ . defaults ( { } , settings , _ . templateSettings ) ;
// Combine delimiters into one regular expression via alternation.
var matcher = new RegExp ( [
( settings . escape || noMatch ) . source ,
( settings . interpolate || noMatch ) . source ,
( settings . evaluate || noMatch ) . source
] . join ( '|' ) + '|$' , 'g' ) ;
// Compile the template source, escaping string literals appropriately.
var index = 0 ;
var source = "__p+='" ;
text . replace ( matcher , function ( match , escape , interpolate , evaluate , offset ) {
source += text . slice ( index , offset )
. replace ( escaper , function ( match ) { return '\\' + escapes [ match ] ; } ) ;
if ( escape ) {
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" ;
}
if ( interpolate ) {
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" ;
}
if ( evaluate ) {
source += "';\n" + evaluate + "\n__p+='" ;
}
index = offset + match . length ;
return match ;
} ) ;
source += "';\n" ;
// If a variable is not specified, place data values in local scope.
if ( ! settings . variable ) source = 'with(obj||{}){\n' + source + '}\n' ;
source = "var __t,__p='',__j=Array.prototype.join," +
"print=function(){__p+=__j.call(arguments,'');};\n" +
source + "return __p;\n" ;
try {
render = new Function ( settings . variable || 'obj' , '_' , source ) ;
} catch ( e ) {
e . source = source ;
throw e ;
}
if ( data ) return render ( data , _ ) ;
var template = function ( data ) {
return render . call ( this , data , _ ) ;
} ;
// Provide the compiled function source as a convenience for precompilation.
template . source = 'function(' + ( settings . variable || 'obj' ) + '){\n' + source + '}' ;
return template ;
} ;
// Add a "chain" function, which will delegate to the wrapper.
_ . chain = function ( obj ) {
return _ ( obj ) . chain ( ) ;
} ;
// OOP
// ---------------
// If Underscore is called as a function, it returns a wrapped object that
// can be used OO-style. This wrapper holds altered versions of all the
// underscore functions. Wrapped objects may be chained.
// Helper function to continue chaining intermediate results.
var result = function ( obj ) {
return this . _chain ? _ ( obj ) . chain ( ) : obj ;
} ;
// Add all of the Underscore functions to the wrapper object.
_ . mixin ( _ ) ;
// Add all mutator Array functions to the wrapper.
each ( [ 'pop' , 'push' , 'reverse' , 'shift' , 'sort' , 'splice' , 'unshift' ] , function ( name ) {
var method = ArrayProto [ name ] ;
_ . prototype [ name ] = function ( ) {
var obj = this . _wrapped ;
method . apply ( obj , arguments ) ;
if ( ( name == 'shift' || name == 'splice' ) && obj . length === 0 ) delete obj [ 0 ] ;
return result . call ( this , obj ) ;
} ;
} ) ;
// Add all accessor Array functions to the wrapper.
each ( [ 'concat' , 'join' , 'slice' ] , function ( name ) {
var method = ArrayProto [ name ] ;
_ . prototype [ name ] = function ( ) {
return result . call ( this , method . apply ( this . _wrapped , arguments ) ) ;
} ;
} ) ;
_ . extend ( _ . prototype , {
// Start chaining a wrapped Underscore object.
chain : function ( ) {
this . _chain = true ;
return this ;
} ,
// Extracts the result from a wrapped and chained object.
value : function ( ) {
return this . _wrapped ;
}
} ) ;
// AMD registration happens at the end for compatibility with AMD loaders
// that may not enforce next-turn semantics on modules. Even though general
// practice for AMD registration is to be anonymous, underscore registers
// as a named module because, like jQuery, it is a base library that is
// popular enough to be bundled in a third party lib, but not be part of
// an AMD load request. Those cases could generate an error when an
// anonymous define() is called outside of a loader request.
if ( typeof define === 'function' && define . amd ) {
define ( 'underscore' , [ ] , function ( ) {
return _ ;
} ) ;
}
} ) . call ( this ) ;
/***/ } ) ,
/***/ 551 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
/ * *
* yaml - validator
* https : //github.com/paazmaya/yaml-validator
*
* Copyright ( c ) Juga Paazmaya < paazmaya @ yahoo . com > ( https : //paazmaya.fi)
* Licensed under the MIT license .
* /
2021-12-24 17:13:55 -05:00
const fs = _ _nccwpck _require _ _ ( 147 ) ;
2021-10-01 03:17:49 -04:00
const yaml = _ _nccwpck _require _ _ ( 917 ) ;
2021-12-24 17:13:55 -05:00
const check = ( _ _nccwpck _require _ _ ( 34 ) . init ) ( ) ;
2021-10-01 03:17:49 -04:00
const FIND _LINENUMBER = /line (\d+)/u ;
class YamlValidatore {
constructor ( options ) {
this . options = Object . assign ( {
log : false ,
structure : false ,
onWarning : null ,
writeJson : false
} , options ) ;
this . logs = [ ] ;
this . nonValidPaths = [ ] ; // list of property paths
this . inValidFilesCount = 0 ;
}
/ * *
* Store log messages
* possible later use by writing a log file .
* @ param { string } msg Error message
* @ returns { void }
* /
errored ( msg ) {
this . logs . push ( msg ) ;
}
/ * *
* Check that the given structure is available .
* @ param { Object } doc Object loaded from Yaml file
* @ param { Object } structure Structure requirements
* @ param { string } parent Address in a dot notation
* @ returns { Array } List of not found structure paths
* /
validateStructure ( doc , structure , parent ) {
let notFound = [ ] ,
current = '' ,
notValid ; // false or path
parent = parent || '' ;
Object . keys ( structure ) . forEach ( ( originKey ) => {
const optional = originKey . endsWith ( '?' ) ;
const key = originKey . replace ( /\?$/u , '' ) ;
current = parent ;
if ( ! check ( structure ) . is ( 'Array' ) ) {
current += ( parent . length > 0 ?
'.' :
'' ) + key ;
}
const item = structure [ originKey ] ;
if ( item instanceof Array ) {
if ( check ( doc ) . has ( key ) && check ( doc [ key ] ) . is ( 'Array' ) ) {
doc [ key ] . forEach ( ( child , index ) => {
if ( item . length > 1 ) {
notValid = this . validateStructure ( [ child ] , [ item [ index ] ] , current + '[' + index + ']' ) ;
}
else {
notValid = this . validateStructure ( [ child ] , item , current + '[' + index + ']' ) ;
}
notFound = notFound . concat ( notValid ) ;
} ) ;
}
else if ( ! optional ) {
notFound . push ( current ) ;
}
}
else if ( typeof item === 'string' ) {
if ( ! check ( doc ) . has ( key ) && optional ) {
notValid = false ;
}
else {
notValid = ! ( ( check ( structure ) . is ( 'Array' ) || check ( doc ) . has ( key ) ) && check ( doc [ key ] ) . is ( item ) ) ;
}
// Key can be a index number when the structure is an array, but passed as a string
notFound . push ( notValid ?
current :
false ) ;
}
else if ( typeof item === 'object' && item !== null ) {
if ( ! optional ) {
notValid = this . validateStructure ( doc [ key ] , item , current ) ;
notFound = notFound . concat ( notValid ) ;
}
}
} ) ;
return notFound . filter ( function filterFalse ( item ) {
return item !== false ;
} ) ;
}
/ * *
* Parse the given Yaml data .
* @ param { string } filepath Yaml file path
* @ param { string } data Yaml data
* @ returns { string | null } Parsed Yaml or null on failure
* /
loadData ( filepath , data ) {
const onWarning = ( error ) => {
this . errored ( filepath + ' > ' + error ) ;
if ( typeof this . options . onWarning === 'function' ) {
this . options . onWarning . call ( this , error , filepath ) ;
}
} ;
let doc ;
try {
doc = yaml . load ( data , {
onWarning : onWarning
} ) ;
}
catch ( error ) {
const findNumber = error . message . match ( FIND _LINENUMBER ) ;
const lineNumber = findNumber && findNumber . length > 0 ?
findNumber [ 1 ] :
'unknown' ;
this . errored ( ` Failed to load the Yaml file " ${ filepath } : ${ lineNumber } " \n ${ error . message } ` ) ;
console . error ( ` ${ filepath } : ${ lineNumber } \n ${ error . message } ` ) ;
return null ;
}
return doc ;
}
/ * *
* Read and parse the given Yaml file .
* @ param { string } filepath Yaml file path
* @ returns { string | null } Parsed Yaml or null on failure
* /
loadFile ( filepath ) {
// Verbose output will tell which file is being read
let data ;
const _self = this ;
try {
data = fs . readFileSync ( filepath , 'utf8' ) ;
}
catch ( err ) {
_self . errored ( filepath + ' > No such file or directory' ) ;
return null ;
}
return this . loadData ( filepath , data ) ;
}
/ * *
* Read the given Yaml file , load and check its structure .
* @ param { string } filepath Yaml file path
* @ returns { number } 0 when no errors , 1 when errors .
* /
checkFile ( filepath ) {
const doc = this . loadFile ( filepath ) ;
if ( ! doc ) {
return 1 ;
}
if ( this . options . writeJson ) {
const json = JSON . stringify ( doc , null , ' ' ) ;
fs . writeFileSync ( filepath . replace ( /\.y(a)?ml$/iu , '.json' ) , json , 'utf8' ) ;
}
if ( this . options . structure ) {
const nonValidPaths = this . validateStructure ( doc , this . options . structure ) ;
if ( nonValidPaths . length > 0 ) {
this . errored ( filepath + ' is not following the correct structure, missing:' ) ;
this . errored ( nonValidPaths . join ( '\n' ) ) ;
this . nonValidPaths = this . nonValidPaths . concat ( nonValidPaths ) ;
return 1 ;
}
}
return 0 ;
}
/ * *
* Create a report out of this , but in reality also run .
* @ param { array } files List of files that have been checked that they exist
* @ returns { void }
* /
validate ( files ) {
const _self = this ;
this . inValidFilesCount = files . map ( ( filepath ) => {
return _self . checkFile ( filepath ) ;
} ) . reduce ( ( prev , curr ) => {
return prev + curr ;
} , _self . inValidFilesCount ) ;
}
/ * *
* Create a report out of this , but in reality also run .
* @ returns { number } 0 when no errors , the count of invalid files otherwise .
* /
report ( ) {
if ( this . inValidFilesCount > 0 ) {
this . errored ( 'Yaml format related errors in ' + this . inValidFilesCount + ' files' ) ;
}
const len = this . nonValidPaths . length ;
this . errored ( 'Total of ' + len + ' structure validation error(s)' ) ;
if ( typeof this . options . log === 'string' ) {
fs . writeFileSync ( this . options . log , this . logs . join ( '\n' ) , 'utf8' ) ;
}
return this . inValidFilesCount ;
}
}
module . exports = YamlValidatore ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 491 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "assert" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 361 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "events" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 147 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "fs" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 685 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "http" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 687 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "https" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 808 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "net" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 37 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "os" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 17 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "path" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 404 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "tls" ) ;
/***/ } ) ,
2021-12-24 17:13:55 -05:00
/***/ 837 :
2021-10-01 03:17:49 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "util" ) ;
/***/ } )
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _nccwpck _require _ _ ( moduleId ) {
2021-10-01 00:58:11 -04:00
/******/ // Check if module is in cache
2021-10-01 03:17:49 -04:00
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
2021-10-01 00:58:11 -04:00
/******/ }
/******/ // 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
/******/ var threw = true ;
/******/ try {
2021-10-01 03:17:49 -04:00
/******/ _ _webpack _modules _ _ [ moduleId ] . call ( module . exports , module , module . exports , _ _nccwpck _require _ _ ) ;
2021-10-01 00:58:11 -04:00
/******/ threw = false ;
/******/ } finally {
/******/ if ( threw ) delete _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ }
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
2021-10-01 03:17:49 -04:00
/******/ if ( typeof _ _nccwpck _require _ _ !== 'undefined' ) _ _nccwpck _require _ _ . ab = _ _dirname + "/" ;
/******/
/************************************************************************/
/******/
2021-10-01 00:58:11 -04:00
/******/ // startup
/******/ // Load entry module and return exports
2021-10-01 03:17:49 -04:00
/******/ // This entry module is referenced by other modules so it can't be inlined
2021-12-24 17:13:55 -05:00
/******/ var _ _webpack _exports _ _ = _ _nccwpck _require _ _ ( 283 ) ;
2021-10-01 03:17:49 -04:00
/******/ module . exports = _ _webpack _exports _ _ ;
/******/
2021-10-01 00:58:11 -04:00
/******/ } ) ( )
;
//# sourceMappingURL=index.js.map