This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
ClosureCompiler.min.js
17 lines (17 loc) · 5.62 KB
/
ClosureCompiler.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
ClosureCompiler.js (c) 2013 Daniel Wirtz <[email protected]>
Released under the Apache License, Version 2.0
see: https://github.com/dcodeIO/ClosureCompiler.js for details
*/
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[e]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var e=0;return $jscomp.iteratorPrototype(function(){return e<a.length?{done:!1,value:a[e++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,e){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,g={next:function(){if(c<a.length){var m=c++;return{value:e(m,a[m]),done:!1}}g.next=function(){return{done:!0,value:void 0}};return g.next()}};g[Symbol.iterator]=function(){return g};return g};
$jscomp.polyfill=function(a,e,c,g){if(e){c=$jscomp.global;a=a.split(".");for(g=0;g<a.length-1;g++){var m=a[g];m in c||(c[m]={});c=c[m]}a=a[a.length-1];g=c[a];e=e(g);e!=g&&null!=e&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:e})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");
(function(a){if("function"!=typeof require||!module||!module.exports||!process)throw Error("ClosureCompiler.js can only be used within node.js");var e=require("path"),c=require("fs"),g=require("child_process"),m=require("bl");c.existsSync||(c.existsSync=e.existsSync);var f=function(a){this.options="object"===typeof a&&a?a:{}};f._assertOption=function(a,c,e){if(0>e.indexOf(c))throw"Illegal "+a+" value: "+c+" ("+e+" expected)";};f.JAVA_EXT="win32"==process.platform?".exe":"";f.getGlobalJava=function(){var a=
null;process.env.JAVA_HOME&&(a=e.join(process.env.JAVA_HOME,"bin","java"+f.JAVA_EXT),c.existsSync(a)||(a=null));a||(a="java");return a};f.getBundledJava=function(){return e.normalize(e.join(__dirname,"jre","bin","java"+f.JAVA_EXT))};f.testJava=function(a,c){g.exec('"'+a+'" -version',{},function(a,e,f){f+="";f.match(/1\.[7-8]+/)?c(!0,null):0<=f.indexOf('version "')?c(!1,Error("Not Java 7")):c(!1,a)})};f.compile=function(a,c,e,g){4>arguments.length&&(g=e,e=null);(new f(c)).compile(a,e,g)};f.prototype.compile=
function(a,q,r){function w(a,b,c,d){var e=m(),f=m();a=g.spawn(a,b,{stdio:[c||"ignore","pipe","pipe"]});a.stdout.pipe(e);a.stderr.pipe(f);a.on("exit",function(a,b){var c;a&&(c=Error(a),c.code=a,c.signal=b);d(c,e,f)});a.on("error",function(a){d(a,e,f)})}function u(a,b){w(a,b,q,function(a,b,c){0<b.length||0<c.length?r(c+"",b+""):r(a,null)})}3>arguments.length&&(r=q,q=null);for(var d={},l=Object.keys(this.options),b=0;b<l.length;b++)d[l[b].toLowerCase()]=this.options[l[b]];delete d.js;delete d.js_output_file;
var b=d.xms||null,h=d.xmx||"1024m";delete d.xms;delete d.xmx;var t;if(d.compiler_jar)t=d.compiler_jar,delete d.compiler_jar;else{var v=__dirname+"/compiler";c.readdirSync(v).forEach(function(a){-1!==a.indexOf("closure-compiler")&&(t=v+"/"+a)})}var n=["-XX:+TieredCompilation"];b&&n.push("-Xms"+b);n.push("-Xmx"+h,"-jar",t);a instanceof Array||(a=[a]);for(b=0;b<a.length;b++){if("string"!=typeof a[b])throw Error("Illegal source file: "+a[b]);if(0<=a[b].indexOf('"'))n.push("--js="+a[b]);else{h=c.statSync(a[b]);
if(!h.isFile())throw Error("Source file not found: "+a[b]);n.push("--js",a[b])}}d.externs||(d.externs=[]);d.externs instanceof Array||(d.externs=[d.externs]);l=[];for(b=0;b<d.externs.length;b++){if("string"!=typeof d.externs[b]||""==d.externs[b])throw Error("Externs directive does not point to a file or directory: "+d.externs[b]);"node"==d.externs[b].toLowerCase()&&(d.externs[b]=__dirname+"/node_modules/closurecompiler-externs");h=c.statSync(d.externs[b]);if(h.isDirectory())for(var p=c.readdirSync(d.externs[b]),
h=0;h<p.length;h++){var k=d.externs[b]+"/"+p[h];c.statSync(k).isFile()&&".js"==e.extname(k).toLowerCase()&&l.push(k)}else if(h.isFile())l.push(d.externs[b]);else throw Error("Externs file not found: "+d.externs[b]);}delete d.externs;for(b=0;b<l.length;b++)n.push("--externs",l[b]);l=Object.keys(d);for(b=0;b<l.length;b++){p=l[b];k=d[l[b]];if(!/[a-zA-Z0-9_]+/.test(p))throw Error("Illegal option: "+p);if(!0===k)n.push("--"+p);else if(!1!==k)for(k instanceof Array||(k=[k]),h=0;h<k.length;h++){if(!/[^\s]*/.test(k[h]))throw Error("Illegal value for option "+
p+": "+k[h]);n.push("--"+p,k[h])}}f.testJava(f.getGlobalJava(),function(a){a?u(f.getGlobalJava(),n):f.testJava(f.getBundledJava(),function(a){if(a)u(f.getBundledJava(),n);else throw Error("Java is not available, neither the bundled nor a global one.");})})};f.prototype.toString=function(){return"ClosureCompiler"};module.exports=f})(this);