This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
143,178 additions
and
17,862 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,337 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Documentation Source: Compiler.js</title> | ||
|
||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/sunlight.dark.css"> | ||
|
||
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css"> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div class="navbar navbar-default navbar-fixed-top navbar-inverse"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="index.html">Documentation</a> | ||
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation"> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
</div> | ||
<div class="navbar-collapse collapse" id="topNavigation"> | ||
<ul class="nav navbar-nav"> | ||
|
||
<li class="dropdown"> | ||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a> | ||
<ul class="dropdown-menu "> | ||
<li><a href="Compiler.html">Compiler</a></li><li><a href="DevServer.html">DevServer</a></li><li><a href="Documentation.html">Documentation</a></li><li><a href="JS.html">JS</a></li><li><a href="JSCompiler.html">JSCompiler</a></li><li><a href="JSLint.html">JSLint</a></li><li><a href="NativeProcess.html">NativeProcess</a></li><li><a href="SASS.html">SASS</a></li><li><a href="SASSCompiler.html">SASSCompiler</a></li><li><a href="SASSLint.html">SASSLint</a></li> | ||
</ul> | ||
</li> | ||
|
||
<li class="dropdown"> | ||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a> | ||
<ul class="dropdown-menu "> | ||
<li><a href="global.html#watch">watch</a></li><li><a href="global.html#yaml">yaml</a></li> | ||
</ul> | ||
</li> | ||
|
||
</ul> | ||
<div class="col-sm-3 col-md-3"> | ||
<form class="navbar-form" role="search"> | ||
<div class="input-group"> | ||
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input"> | ||
<div class="input-group-btn"> | ||
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
<div class="container" id="toc-content"> | ||
<div class="row"> | ||
|
||
|
||
<div class="col-md-12"> | ||
|
||
<div id="main"> | ||
|
||
|
||
<h1 class="page-title">Source: Compiler.js</h1> | ||
|
||
<section> | ||
<article> | ||
<pre | ||
class="sunlight-highlight-javascript linenums">/* @flow */ | ||
|
||
import mkdirp from 'mkdirp'; | ||
import {dirname} from 'path'; | ||
import {writeFile} from 'fs'; | ||
import {gzip} from 'zlib'; | ||
|
||
let i = 0; | ||
|
||
/** | ||
* Processed application code with source maps | ||
* | ||
* @typedef {Object} ProgramData | ||
* @property {string} code - program code | ||
* @property {string} map - source map json string | ||
*/ | ||
export type ProgramData = {code: string, map: string}; | ||
|
||
/** | ||
* The base compiler class | ||
* | ||
* @class Compiler | ||
*/ | ||
export default class Compiler { | ||
/** | ||
* True if the NODE_ENV environment variable is equal to 'production'. | ||
* Caution: modifying it's value directly may lead to unexpected results | ||
* | ||
* @member {boolean} isProduction | ||
* @memberof Compiler | ||
* @readOnly | ||
* @instance | ||
*/ | ||
isProduction: boolean; | ||
|
||
constructor() { | ||
this.isProduction = 'production' === process.env.NODE_ENV; | ||
} | ||
|
||
/** | ||
* Minifies the compiled code | ||
* | ||
* @memberOf Compiler | ||
* @instance | ||
* @abstract | ||
* @method minify | ||
* @param {string} path - a path to the file (can be used for the sourceMappingURL comment) | ||
* @param {ProgramData} data - the actual program data to compress | ||
* @return {ProgramData} processed application code with source maps or null on error | ||
*/ | ||
minify: (path: string, data: ProgramData) => ?ProgramData; | ||
|
||
/** | ||
* Executed when the compilation is complete | ||
* | ||
* @memberOf Compiler | ||
* @instance | ||
* @protected | ||
* @method done | ||
* @param {string} inPath - the input path | ||
* @param {Function} callback - a callback function | ||
* @example | ||
* compiler.done('/path/to/an/input/file', callback); | ||
*/ | ||
done(inPath: string, callback: () => void) { | ||
console.log('\x1b[32m%s. Compiled %s\x1b[0m', ++i, inPath); | ||
callback(); | ||
} | ||
|
||
/** | ||
* Writes the data to disk | ||
* | ||
* @memberOf Compiler | ||
* @instance | ||
* @protected | ||
* @method fsWrite | ||
* @param {string} path - the output path | ||
* @param {ProgramData} data - the data to write | ||
* @param {Function} callback - a callback function | ||
* @example | ||
* compiler.fsWrite('/path/to/an/output/file', data, callback); | ||
*/ | ||
fsWrite(path: string, data: ProgramData, callback: () => void) { | ||
mkdirp(dirname(path), mkdirpErr => { | ||
if (mkdirpErr) { | ||
return console.error(mkdirpErr); | ||
} | ||
writeFile(path, data.code, scriptErr => { | ||
if (scriptErr) { | ||
return console.error(scriptErr); | ||
} | ||
if (!data.map) { | ||
return callback(); | ||
} | ||
writeFile(`${path}.map`, data.map, mapErr => { | ||
if (mapErr) { | ||
return console.error(mapErr); | ||
} | ||
callback(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
* Minifies and g-zips the program | ||
* | ||
* @memberOf Compiler | ||
* @instance | ||
* @protected | ||
* @method optimize | ||
* @param {string} inPath - the input path | ||
* @param {string} outPath - the output path | ||
* @param {ProgramData} data - processed application code with source maps | ||
* @param {Function} callback - a callback function | ||
* @example | ||
* compiler.optimize('/path/to/an/input/file', '/path/to/the/output/file', data, callback); | ||
*/ | ||
optimize(inPath: string, outPath: string, data: ProgramData, callback: () => void) { | ||
const minified = this.minify(outPath, data); | ||
|
||
if (!minified) { | ||
return; | ||
} | ||
gzip(minified.code, (gzipErr, code) => { | ||
if (gzipErr) { | ||
return console.error(gzipErr); | ||
} | ||
this.fsWrite(outPath, {code, map: minified.map}, () => { | ||
this.done(inPath, callback); | ||
}); | ||
}); | ||
} | ||
|
||
} | ||
</pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
</div> | ||
</div> | ||
|
||
<div class="clearfix"></div> | ||
|
||
|
||
|
||
</div> | ||
</div> | ||
|
||
<div class="modal fade" id="searchResults"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
<h4 class="modal-title">Search results</h4> | ||
</div> | ||
<div class="modal-body"></div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | ||
</div> | ||
</div><!-- /.modal-content --> | ||
</div><!-- /.modal-dialog --> | ||
</div> | ||
|
||
<footer> | ||
|
||
|
||
<span class="jsdoc-message"> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> | ||
|
||
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. | ||
</span> | ||
</footer> | ||
|
||
<script src="scripts/docstrap.lib.js"></script> | ||
<script src="scripts/toc.js"></script> | ||
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script> | ||
|
||
<script> | ||
$( function () { | ||
$( "[id*='$']" ).each( function () { | ||
var $this = $( this ); | ||
|
||
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) ); | ||
} ); | ||
|
||
$( ".tutorial-section pre, .readme-section pre" ).each( function () { | ||
var $this = $( this ); | ||
|
||
var example = $this.find( "code" ); | ||
exampleText = example.html(); | ||
var lang = /{@lang (.*?)}/.exec( exampleText ); | ||
if ( lang && lang[1] ) { | ||
exampleText = exampleText.replace( lang[0], "" ); | ||
example.html( exampleText ); | ||
lang = lang[1]; | ||
} else { | ||
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/); | ||
lang = langClassMatch ? langClassMatch[1] : "javascript"; | ||
} | ||
|
||
if ( lang ) { | ||
|
||
$this | ||
.addClass( "sunlight-highlight-" + lang ) | ||
.addClass( "linenums" ) | ||
.html( example.html() ); | ||
|
||
} | ||
} ); | ||
|
||
Sunlight.highlightAll( { | ||
lineNumbers : true, | ||
showMenu : true, | ||
enableDoclinks : true | ||
} ); | ||
|
||
$.catchAnchorLinks( { | ||
navbarOffset: 10 | ||
} ); | ||
$( "#toc" ).toc( { | ||
anchorName : function ( i, heading, prefix ) { | ||
var id = $( heading ).attr( "id" ); | ||
return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i ); | ||
}, | ||
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4", | ||
showAndHide : false, | ||
smoothScrolling: true | ||
} ); | ||
|
||
$( "#main span[id^='toc']" ).addClass( "toc-shim" ); | ||
$( '.dropdown-toggle' ).dropdown(); | ||
|
||
$( "table" ).each( function () { | ||
var $this = $( this ); | ||
$this.addClass('table'); | ||
} ); | ||
|
||
} ); | ||
</script> | ||
|
||
|
||
|
||
<!--Navigation and Symbol Display--> | ||
|
||
|
||
<!--Google Analytics--> | ||
|
||
|
||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
SearcherDisplay.init(); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.